diff --git a/src/components/Dashboard/Identity.tsx b/src/components/Dashboard/Identity.tsx index eef32b2f4ee7..85cd2a6d9c28 100644 --- a/src/components/Dashboard/Identity.tsx +++ b/src/components/Dashboard/Identity.tsx @@ -14,9 +14,7 @@ export interface IIdentity { fingerprint: string } interface Props extends IIdentity { - /* Design variant */ avatar?: string - atSymbolBefore?: boolean onClick?(): void } const FixedWidth = createBox({ fontFamily: FixedWidthFonts }) @@ -39,34 +37,34 @@ export default withStylesTyped(theme => avatarDisabled: { marginRight: 0, }, + emptyAvatar: { + width: 0, + height: 0, + }, }), -)(function Identity(props) { - const { avatar, onClick } = props +)(function({ avatar, onClick, classes, nickname, fingerprint, username }) { return ( - + 3 ? avatar : undefined}> + 3 ? avatar : undefined}> {avatar.length <= 3 ? avatar : undefined} ) : ( - + ) } title={ <> - - {props.nickname} - - - {props.atSymbolBefore && '@'} - {props.username} + + {nickname} + {username} } - subheader={{props.fingerprint}} + subheader={{fingerprint}} /> ) diff --git a/src/components/InjectedComponents/AddToKeyStore.tsx b/src/components/InjectedComponents/AddToKeyStore.tsx index 2a3f44117fe6..a2d0029480f7 100644 --- a/src/components/InjectedComponents/AddToKeyStore.tsx +++ b/src/components/InjectedComponents/AddToKeyStore.tsx @@ -22,7 +22,7 @@ export const AddToKeyStoreUI = { success: , awaiting: , failed: (props: { error: Error }) => ( - Maskbook public key NOT verified ❌}> + {props.error.message} This public key won't be saved.{console.error(props.error)} ), diff --git a/src/components/InjectedComponents/AdditionalPostContent.tsx b/src/components/InjectedComponents/AdditionalPostContent.tsx index e9f1e97fc8f9..176f20e4e16c 100644 --- a/src/components/InjectedComponents/AdditionalPostContent.tsx +++ b/src/components/InjectedComponents/AdditionalPostContent.tsx @@ -2,24 +2,44 @@ import * as React from 'react' import Divider from '@material-ui/core/Divider/Divider' import Typography from '@material-ui/core/Typography/Typography' import { getUrl } from '../../utils/utils' +import { withStylesTyped } from '../../utils/theme' interface Props { title: React.ReactNode children?: any } -export const AdditionalContent = (props: Props) => { +export const AdditionalContent = withStylesTyped({ + upDivider: { + marginBottom: 6, + // TODO: ? is this useful? + marginBlock: 6, + }, + title: { + display: 'flex', + }, + icon: { + transform: 'translate(-1px, -1px)', + width: 16, + height: 16, + }, + content: { + marginBottom: 6, + marginTop: 6, + lineHeight: 1.2, + }, +})(({ classes, ...props }) => { const icon = getUrl('/maskbook-icon-padded.png') return ( <> - - - + + + {props.title} - + {props.children} ) -} +}) diff --git a/src/components/InjectedComponents/DecryptedPost.tsx b/src/components/InjectedComponents/DecryptedPost.tsx index 20496f8c8970..10230652d353 100644 --- a/src/components/InjectedComponents/DecryptedPost.tsx +++ b/src/components/InjectedComponents/DecryptedPost.tsx @@ -6,25 +6,20 @@ import { CryptoService } from '../../extension/content-script/rpc' import { useShareMenu } from './SelectPeopleDialog' import { Person } from '../../extension/background-script/PeopleService' import Link from '@material-ui/core/Link' +import { withStylesTyped } from '../../utils/theme' -interface Props { - postBy: string - whoAmI: string - encryptedText: string - people: Person[] -} -function DecryptPostSuccess({ - data, - displayAddDecryptor, - requestAddDecryptor, - people, -}: { +interface DecryptPostSuccessProps { data: { signatureVerifyResult: boolean; content: string } displayAddDecryptor: boolean requestAddDecryptor(to: Person[]): Promise people: Person[] -}) { - const { ShareMenu, hideShare, showShare } = useShareMenu(people, requestAddDecryptor) +} +const DecryptPostSuccess = withStylesTyped({ + link: { marginRight: '1em', cursor: 'pointer' }, + pass: { color: 'green' }, + fail: { color: 'red' }, +})(({ data, displayAddDecryptor, requestAddDecryptor, people, classes }) => { + const { ShareMenu, showShare } = useShareMenu(people, requestAddDecryptor) return ( {displayAddDecryptor ? ( - + Add decryptor ) : null} {data.signatureVerifyResult ? ( - Signature verified ✔ + Signature verified ✔ ) : ( - Signature NOT verified ❌ + Signature NOT verified ❌ )} } @@ -52,7 +47,7 @@ function DecryptPostSuccess({ )} /> ) -} +}) const DecryptPostAwaiting = function DecryptPostFailed({ error }: { error: Error }) { @@ -66,7 +61,13 @@ function DecryptPostFailed({ error }: { error: Error }) { ) } -function DecryptPost({ postBy, whoAmI, encryptedText, people }: Props) { +interface DecryptPostProps { + postBy: string + whoAmI: string + encryptedText: string + people: Person[] +} +function DecryptPost({ postBy, whoAmI, encryptedText, people }: DecryptPostProps) { const [_, a] = encryptedText.split('🎼') const [b, _2] = a.split(':||') return ( diff --git a/src/components/InjectedComponents/SelectPeopleDialog.tsx b/src/components/InjectedComponents/SelectPeopleDialog.tsx index 7382b7ed77f0..caac9e0ba38f 100644 --- a/src/components/InjectedComponents/SelectPeopleDialog.tsx +++ b/src/components/InjectedComponents/SelectPeopleDialog.tsx @@ -7,13 +7,18 @@ import Button from '@material-ui/core/Button/Button' import DialogTitle from '@material-ui/core/DialogTitle/DialogTitle' import DialogActions from '@material-ui/core/DialogActions/DialogActions' import DialogContent from '@material-ui/core/DialogContent/DialogContent' +import { withStylesTyped } from '../../utils/theme' interface Props { open: boolean people: Person[] onClose(): void onSelect(people: Person[]): Promise } -export function SelectPeopleDialog(props: Props) { +export const SelectPeopleDialog = withStylesTyped({ + title: { paddingBottom: 0 }, + content: { padding: '0 12px' }, + progress: { marginRight: 6 }, +})(({ classes, ...props }) => { const [people, select] = useState([] as Person[]) const [committed, setCommitted] = useState(false) const onClose = useCallback(() => { @@ -29,8 +34,8 @@ export function SelectPeopleDialog(props: Props) { // useEsc(() => (committed ? void 0 : onClose)) return ( - Share to ... - + Share to ... + @@ -38,13 +43,13 @@ export function SelectPeopleDialog(props: Props) { Cancel ) -} +}) export function useShareMenu(people: Person[], onSelect: (people: Person[]) => Promise) { const [show, setShow] = useState(false) @@ -53,7 +58,7 @@ export function useShareMenu(people: Person[], onSelect: (people: Person[]) => P return { showShare, - hideShare, + // hideShare, ShareMenu: , } } diff --git a/src/components/Welcomes/1a2.tsx b/src/components/Welcomes/1a2.tsx index d79c2d1c2794..3fdb9746bf47 100644 --- a/src/components/Welcomes/1a2.tsx +++ b/src/components/Welcomes/1a2.tsx @@ -23,12 +23,16 @@ export default withStylesTyped(theme => button: { minWidth: 180, }, + img: { + border: '1px solid #ddd', + borderRadius: 5, + }, }), )(function Welcome({ classes, next }) { return ( Encrypt message use this postbox - + Then only people you selected with Maskbook can see the post content diff --git a/src/components/Welcomes/1a4.tsx b/src/components/Welcomes/1a4.tsx index 0cee54f7486c..f66206aee999 100644 --- a/src/components/Welcomes/1a4.tsx +++ b/src/components/Welcomes/1a4.tsx @@ -42,6 +42,12 @@ export default withStylesTyped(theme => button: { minWidth: 180, }, + textFieldShort: { + minHeight: '10em', + }, + textFieldLong: { + minHeight: '11em', + }, }), )(function Welcome({ classes, copyToClipboard, provePost }) { const full = `I'm using https://maskbook.io/ to encrypt my posts to prevent Facebook from peeping into them. @@ -71,7 +77,7 @@ ${provePost}` onFocus={onFocus} onBlur={onBlur} value={showShort ? provePost : full} - style={{ minHeight: showShort ? '10em' : '11em' }} + className={showShort ? classes.textFieldShort : classes.textFieldLong} /> {showShort diff --git a/src/components/Welcomes/1b1.tsx b/src/components/Welcomes/1b1.tsx index f6b3972a5639..44f6e21fb0d1 100644 --- a/src/components/Welcomes/1b1.tsx +++ b/src/components/Welcomes/1b1.tsx @@ -54,6 +54,16 @@ export default withStylesTyped(theme => button: { minWidth: 180, }, + file: { + display: 'none', + }, + restoreBox: { + color: 'gray', + transition: '0.4s', + '&[data-active=true]': { + color: 'black', + }, + }, }), )(function Welcome({ classes, back, restore }) { const ref = React.useRef(null) @@ -70,16 +80,15 @@ export default withStylesTyped(theme => Restore your keypair
ref.current && ref.current.click()}> {dragStatus === 'drag-enter' ? 'Drag your key backup into this dialog' diff --git a/src/stories/index.tsx b/src/stories/index.tsx index 3e184e03ef2c..7e75e6e36e3b 100644 --- a/src/stories/index.tsx +++ b/src/stories/index.tsx @@ -69,7 +69,6 @@ storiesOf('Dashboard (unused)', module) fingerprint={text('Fingerprint', 'FDFE333CE20ED446AD88F3C8BA3AD1AA5ECAF521')} nickname={text('Name', 'Jack Works')} username={text('Username', 'jackworks_vfs')} - atSymbolBefore={boolean('Add a @ on username?', false)} /> )) .add('Dashboard (unused)', () => ( @@ -133,7 +132,7 @@ storiesOf('Injections', module) }) .add('Select people dialog', () => { function SelectPeople() { - const { ShareMenu, hideShare, showShare } = useShareMenu(demoPeople, async people => sleep(3000)) + const { ShareMenu, showShare } = useShareMenu(demoPeople, async people => sleep(3000)) return ( <> {ShareMenu} diff --git a/src/utils/theme.ts b/src/utils/theme.ts index 6d430ba7316e..0d5b9750455a 100644 --- a/src/utils/theme.ts +++ b/src/utils/theme.ts @@ -1,8 +1,8 @@ import withStyles, { WithStyles, WithStylesOptions, - StyleRules, StyleRulesCallback, + StyleRules, } from '@material-ui/core/styles/withStyles' import React from 'react' import createMuiTheme, { ThemeOptions, Theme } from '@material-ui/core/styles/createMuiTheme' @@ -67,9 +67,10 @@ const baseTheme = (theme: 'dark' | 'light') => export const MaskbookLightTheme = createMuiTheme(baseTheme('light')) export const MaskbookDarkTheme = createMuiTheme(baseTheme('dark')) export const FixedWidthFonts = `Droid Sans Mono', Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif` + // 类型安全的 withStyles export function withStylesTyped = {}>( - style: StyleRulesCallback | StyleRules, + style: StyleRulesCallback | StyleRules = {} as any, options?: Options, ) { return function(