Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add options page && popup page #71

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,25 @@
"manifest_iconTitle": {
"message": "[loading……]"
},
"global_btn_ok": {
"message": "ok"
},
"component_developerCollabrationNetwork_title": {
"message": "Developer Collabration Network"
},
"options_header_settings": {
"message": "Settings"
},
"options_header_commandLine": {
"message": "Commandline"
},
"options_toggle_checkForUpdates": {
"message": "check updates"
},
"options_toggle_checkForUpdates_onText": {
"message": "on"
},
"options_toggle_checkForUpdates_offText": {
"message": "off"
}
}
18 changes: 18 additions & 0 deletions src/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,25 @@
"manifest_iconTitle": {
"message": "[载入中……]"
},
"global_btn_ok": {
"message": "确定"
},
"component_developerCollabrationNetwork_title": {
"message": "开发人员合作网络图"
},
"options_header_settings": {
"message": "设置"
},
"options_header_commandLine": {
"message": "命令行"
},
"options_toggle_checkForUpdates": {
"message": "自动检测更新"
},
"options_toggle_checkForUpdates_onText": {
"message": "开"
},
"options_toggle_checkForUpdates_offText": {
"message": "关"
}
}
11 changes: 11 additions & 0 deletions src/components/OptionsPage/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.container{
width: 98vw;
min-height: calc(100vh - 100px);
margin-top: 10px;
opacity: 1;
background: white;
box-shadow: rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px, rgba(0, 0, 0, 0.2) 0px 3px 1px -2px;
transition: all 0.2s ease 0s;
border-radius: 3px;
overflow: hidden;
}
80 changes: 80 additions & 0 deletions src/components/OptionsPage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React from 'react';
import {
Pivot, PivotItem, PivotLinkFormat,Stack, Toggle,DefaultButton
} from 'office-ui-fabric-react';
import { initializeIcons } from '@uifabric/icons';
import {getMessageI18n} from '../../utils/utils'
import './index.css';

initializeIcons();

const OptionsPage: React.FC<{}> = () => {

return(
<Stack>
<Stack horizontalAlign="center">
<h1>HYPERTRONS</h1>
<sub>version 0.1.2</sub>
</Stack>
<Stack horizontalAlign="center">
<div className="container">
<Pivot
style={{margin:"3px"}}
linkFormat={PivotLinkFormat.tabs}
>
<PivotItem headerText={getMessageI18n("options_header_settings")} itemIcon="Settings">
<Stack
horizontalAlign="space-around"
verticalAlign='center'
style={{margin:"5px",padding:"3px"}}
tokens={{
childrenGap: 10
}}
>
<Stack
horizontalAlign="start"
verticalAlign='center'
horizontal
tokens={{
childrenGap: 10
}}
>
<DefaultButton
style={{width:100}}
onClick={()=>{}}
>
{getMessageI18n("global_btn_ok")}
</DefaultButton>
</Stack>
<Toggle
label={getMessageI18n('options_toggle_checkForUpdates')}
defaultChecked
onText={getMessageI18n('options_toggle_checkForUpdates_onText')}
offText={getMessageI18n('options_toggle_checkForUpdates_offText')}
onChange={(e,checked)=>{

}}
/>

</Stack>
</PivotItem>
<PivotItem headerText={getMessageI18n("options_header_commandLine")} itemIcon="CommandPrompt">
<Stack
horizontalAlign="space-around"
verticalAlign='center'
style={{margin:"5px",padding:"3px"}}
tokens={{
childrenGap: 10
}}
>

</Stack>
</PivotItem>
</Pivot>
</div>
</Stack>
</Stack>
)
}

export default OptionsPage;
Empty file.
19 changes: 19 additions & 0 deletions src/components/PopupPage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import {
Stack
} from 'office-ui-fabric-react';
import { initializeIcons } from '@uifabric/icons';
import './index.css';

initializeIcons();

const PopupPage: React.FC<{}> = () => {

return(
<Stack horizontalAlign="center">
<h1>Hypertrons</h1>
</Stack>
)
}

export default PopupPage;
1 change: 1 addition & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Hypertrons",
"default_locale": "zh_CN",
"options_page": "options.html",
"icons": {
"128": "128.png"
},
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Options/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render } from 'react-dom';
import OptionsPage from '../../components/OptionsPage/index'

import './index.css';

render(<div />, window.document.querySelector('#app-container'));
render(<OptionsPage />, window.document.querySelector('#app-container'));
3 changes: 2 additions & 1 deletion src/pages/Popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render } from 'react-dom';
import PopupPage from '../../components/PopupPage/index'

import './index.css';

render(<div />, window.document.querySelector('#app-container'));
render(<PopupPage />, window.document.querySelector('#app-container'));
4 changes: 4 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ export async function chrome_get(key:string){
})
});
}

export function getMessageI18n(key:string){
return chrome.i18n.getMessage(key);
}