-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d75dc94
commit 48e0f65
Showing
20 changed files
with
3,079 additions
and
3,341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
parser : '@typescript-eslint/parser', | ||
extends : [ | ||
'plugin:react/recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier/@typescript-eslint', | ||
'plugin:prettier/recommended' | ||
], | ||
parserOptions : { | ||
ecmaVersion : 2018, | ||
sourceType : 'module', | ||
ecmaFeatures : { | ||
jsx : true | ||
} | ||
}, | ||
settings : { | ||
react : { | ||
version : 'detect' | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
semi : true, | ||
trailingComma : 'all', | ||
singleQuote : true, | ||
printWidth : 120, | ||
tabWidth : 2 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
, | ||
"editor.formatOnSave": true, | ||
"eslint.autoFixOnSave": true, | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
{ | ||
"language": "typescript", | ||
"autoFix": true | ||
}, | ||
{ | ||
"language": "typescriptreact", | ||
"autoFix": true | ||
} | ||
], | ||
"editor.renderWhitespace": "boundary", | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(process.version); |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,73 @@ | ||
import React from 'react'; | ||
import logo from './logo.svg'; | ||
|
||
function App() { | ||
import logo from './logo.jpg'; | ||
import { useGlobalState, useSetGlobaleState } from './Store'; | ||
|
||
import { | ||
Grid, | ||
Typography, | ||
createMuiTheme, | ||
Card, | ||
CardActionArea, | ||
CardMedia, | ||
CardContent, | ||
CardActions, | ||
Checkbox, | ||
FormControlLabel, | ||
FormControl, | ||
InputLabel, | ||
Select, | ||
MenuItem, | ||
} from '@material-ui/core'; | ||
|
||
const App = () => { | ||
const [state, setState] = [useGlobalState(), useSetGlobaleState()]; | ||
const handleCheckbox = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setState({ ...state, [`${event.target.name}`]: event.target.checked }); | ||
}; | ||
const handleSelect = (event: React.ChangeEvent<{ value: unknown }>) => { | ||
setState({ ...state, set: event.target.value || 'apple' }); | ||
}; | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.tsx</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
<Card className="App"> | ||
<CardActionArea> | ||
<CardMedia | ||
component="img" | ||
alt="Contemplative Reptile" | ||
height="300" | ||
image={logo} | ||
title="Contemplative Reptile" | ||
/> | ||
<CardContent> | ||
<Typography gutterBottom variant="h5" component="h2"> | ||
Xmoji | ||
</Typography> | ||
<Typography variant="body2" color="textSecondary" component="p"> | ||
You can open the Emoji picker tab with shortcut <code>Ctrl + Win(Command) + Space</code> | ||
</Typography> | ||
</CardContent> | ||
</CardActionArea> | ||
<CardActions> | ||
<FormControlLabel | ||
control={<Checkbox checked={state.darkMode} name="darkMode" color="primary" onChange={handleCheckbox} />} | ||
label="Dark Mode" | ||
/>{' '} | ||
<FormControlLabel | ||
control={<Checkbox checked={state.startup} name="startup" color="primary" onChange={handleCheckbox} />} | ||
label="Run in startup" | ||
/> | ||
<FormControl> | ||
<InputLabel id="demo-simple-select-label">Set</InputLabel> | ||
<Select labelId="demo-simple-select-label" id="demo-simple-select" onChange={handleSelect} value={state.set}> | ||
<MenuItem value={'apple'}>Apple</MenuItem> | ||
<MenuItem value={'google'}>Google</MenuItem> | ||
<MenuItem value={'twitter'}>Twitter</MenuItem> | ||
<MenuItem value={'facebook'}>Facebook</MenuItem> | ||
</Select> | ||
</FormControl> | ||
</CardActions> | ||
</Card> | ||
); | ||
} | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import 'emoji-mart/css/emoji-mart.css'; | ||
import { Picker } from 'emoji-mart'; | ||
import { useGlobalState, useSetGlobaleState } from '../Store'; | ||
import { useClipboard } from 'use-clipboard-copy'; | ||
const { remote } = window.require('electron'); | ||
const EmojiTab = () => { | ||
const [state, setState] = [useGlobalState(), useSetGlobaleState()]; | ||
const [emojis, setEmojis] = useState<any>([]); | ||
const clipboard = useClipboard(); | ||
const handleEsc = (event: any) => { | ||
if (event.keyCode === 27) { | ||
const currentWindow = remote.getCurrentWindow(); | ||
|
||
currentWindow.close(); | ||
} | ||
}; | ||
const handleSelect = (emoji: any) => { | ||
setEmojis([...emojis, emoji.native]); | ||
clipboard.copy(emojis.join('')); | ||
}; | ||
|
||
useEffect(() => { | ||
document.addEventListener('keydown', handleEsc, false); | ||
|
||
return () => { | ||
document.removeEventListener('keydown', handleEsc, false); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div className=""> | ||
<Picker | ||
set={state.set} | ||
theme={state.darkMode ? 'dark' : 'light'} | ||
style={{ position: 'absolute', width: '100%', height: '100%' }} | ||
onSelect={handleSelect} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EmojiTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import GlobalInterface from './interfaces/GlobalInterface'; | ||
const electronStore = window.require('electron-store'); | ||
const config = new electronStore(); | ||
const StateContext = React.createContext<GlobalInterface | undefined>(undefined); | ||
const SetStateContext = React.createContext<any | undefined>(undefined); | ||
|
||
if (!config.get('xmoji')) config.set('xmoji', { set: 'apple', darkMode: true, startup: true }); | ||
|
||
export const useGlobalState = () => { | ||
const context = React.useContext(StateContext); | ||
if (context === undefined) { | ||
throw new Error('useCountState must be used within a CountProvider'); | ||
} | ||
return context; | ||
}; | ||
export const useSetGlobaleState = () => { | ||
const context = React.useContext(SetStateContext); | ||
if (context === undefined) { | ||
throw new Error('useCountState must be used within a CountProvider'); | ||
} | ||
return context; | ||
}; | ||
export const StateProvider = ({ children }: { children: React.ReactNode }) => { | ||
const [state, setState] = React.useState(config.get('xmoji')); | ||
React.useEffect(() => { | ||
config.set('xmoji', state); | ||
}, [state]); | ||
return ( | ||
<StateContext.Provider value={state}> | ||
<SetStateContext.Provider value={setState}>{children}</SetStateContext.Provider> | ||
</StateContext.Provider> | ||
); | ||
}; |
Oops, something went wrong.