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 new theme color #6094

Merged
merged 7 commits into from
Apr 28, 2022
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
11 changes: 10 additions & 1 deletion packages/mask/src/plugins/ITO/SNSAdaptor/PostInspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { isCompactPayload } from './helpers'
import { usePoolPayload } from './hooks/usePoolPayload'
import type { JSON_PayloadInMask } from '../types'
import { ITO, ITO_Error, ITO_Loading } from './ITO'
import { useClassicMaskSNSPluginTheme } from '../../../utils'
import { ThemeProvider } from '@mui/material'

export interface PostInspectorProps {
payload: JSON_PayloadInMask
Expand Down Expand Up @@ -92,5 +94,12 @@ export function PostInspector(props: PostInspectorProps) {
/>
)
}
return <EthereumChainBoundary chainId={chain_id}>{renderITO()}</EthereumChainBoundary>

const theme = useClassicMaskSNSPluginTheme()

return (
<ThemeProvider theme={theme}>
<EthereumChainBoundary chainId={chain_id}>{renderITO()}</EthereumChainBoundary>
</ThemeProvider>
)
}
15 changes: 10 additions & 5 deletions packages/mask/src/plugins/Snapshot/SNSAdaptor/PostInspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { getProposalIdentifier } from './helpers'
import { Snapshot } from './Snapshot'
import { LoadingFailCard } from './LoadingFailCard'
import { useRetry } from './hooks/useRetry'
import { ThemeProvider } from '@mui/material'
import { useClassicMaskSNSPluginTheme } from '../../../utils'

export interface PostInspectorProps {
url: string
Expand All @@ -11,11 +13,14 @@ export interface PostInspectorProps {
export function PostInspector(props: PostInspectorProps) {
const identifier = getProposalIdentifier(props.url)
const retry = useRetry()
const theme = useClassicMaskSNSPluginTheme()
return (
<SnapshotContext.Provider value={identifier}>
<LoadingFailCard title="" isFullPluginDown retry={retry}>
<Snapshot />
</LoadingFailCard>
</SnapshotContext.Provider>
<ThemeProvider theme={theme}>
<SnapshotContext.Provider value={identifier}>
<LoadingFailCard title="" isFullPluginDown retry={retry}>
<Snapshot />
</LoadingFailCard>
</SnapshotContext.Provider>
</ThemeProvider>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export function VotingCard() {
offChain>
<Button
className={classes.button}
variant="contained"
disabled={choice === 0 || !account || !power}
onClick={() => setOpen(true)}>
{Boolean(power) && Boolean(account) ? t('plugin_snapshot_vote') : t('plugin_snapshot_no_power')}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,34 @@
"700": "#536471",
"300": "#b9cad3",
"200": "#cfd9de",
"50": "#eff3f4"
"50": "#eff3f4",
"primary": "linear-gradient(0deg, rgba(7, 16, 27, 0.3), rgba(7, 16, 27, 0.3)), #FFFFFF",
"secondary": "linear-gradient(0deg, rgba(7, 16, 27, 0.2), rgba(7, 16, 27, 0.2)), #FFFFFF",
"third": "linear-gradient(0deg, rgba(7, 16, 27, 0.05), rgba(7, 16, 27, 0.05)), #FFFFFF"
},
"public": {
"primary": "#1C68F3",
"success": "#3DC233",
"warning": "#FFB100",
"danger": "#FF3545",
"white": "#ffffff",
"dark": "#07101B",
"secondaryDark": "#767F8D"
},
"text": {
"primary": "#0f1419",
"primary": "#07101B",
"secondary": "#536471",
"third": "#ACB4C1",
"strong": "#111418",
"buttonText": "#FFFFFF"
},
"background": {
"default": "#F6F8F8",
"input": "#EDF1F2",
"default": "#F9F9F9",
"input": "#F2F6FA",
"tipMask": "rgba(0, 0, 0, 0.85)",
"messageShadow": "rgba(101, 119, 134, 0.2)"
"messageShadow": "rgba(101, 119, 134, 0.2)",
"paper": "#ffffff",
"modalTitle": "linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 100%), linear-gradient(90deg, rgba(98, 152, 234, 0.2) 1.03%, rgba(98, 152, 234, 0.2) 1.04%, rgba(98, 126, 234, 0.2) 100%)"
},
"error": {
"main": "#F4212E"
Expand All @@ -34,19 +49,34 @@
"700": "#3b4c5c",
"300": "#697987",
"200": "#697987",
"50": "#cfd9de"
"50": "#cfd9de",
"primary": "linear-gradient(0deg, rgba(7, 16, 27, 0.3), rgba(7, 16, 27, 0.3)), #FFFFFF",
"secondary": "linear-gradient(0deg, rgba(7, 16, 27, 0.2), rgba(7, 16, 27, 0.2)), #FFFFFF",
"third": "linear-gradient(0deg, rgba(7, 16, 27, 0.05), rgba(7, 16, 27, 0.05)), #FFFFFF"
},
"text": {
"primary": "#0f1419",
"secondary": "#536471",
"primary": "#07101B",
"secondary": "#767F8D",
"strong": "#111418",
"buttonText": "#FFFFFF"
"buttonText": "#FFFFFF",
"third": "#ACB4C1"
},
"public": {
"primary": "#1C68F3",
"success": "#3DC233",
"warning": "#FFB100",
"danger": "#FF3545",
"white": "#ffffff",
"dark": "#07101B",
"secondaryDark": "#767F8D"
},
"background": {
"default": "#F6F8F8",
"input": "#EDF1F2",
"default": "#F9F9F9",
"input": "#F2F6FA",
"tipMask": "rgba(0, 0, 0, 0.85)",
"messageShadow": "rgba(101, 119, 134, 0.2)"
"messageShadow": "rgba(101, 119, 134, 0.2)",
"paper": "#ffffff",
"modalTitle": "linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 100%), linear-gradient(90deg, rgba(98, 152, 234, 0.2) 1.03%, rgba(98, 152, 234, 0.2) 1.04%, rgba(98, 126, 234, 0.2) 100%)"
},
"error": {
"main": "#FF5555"
Expand All @@ -64,19 +94,34 @@
"700": "#8899a6",
"300": "#6b7d8c",
"200": "#3d5466",
"50": "#253341"
"50": "#253341",
"primary": "linear-gradient(0deg, rgba(245, 245, 245, 0.3), rgba(245, 245, 245, 0.3)), #000000",
"secondary": "linear-gradient(0deg, rgba(245, 245, 245, 0.1), rgba(245, 245, 245, 0.1)), #000000",
"third": "linear-gradient(0deg, rgba(245, 245, 245, 0.1), rgba(245, 245, 245, 0.1)), #000000"
},
"public": {
"primary": "#1C68F3",
"success": "#3DC233",
"warning": "#FFB100",
"danger": "#FF3545",
"white": "#ffffff",
"dark": "#07101B",
"secondaryDark": "#767F8D"
},
"text": {
"primary": "#EFF3F4",
"primary": "#F5F5F5",
"secondary": "#8899A6",
"third": "#666C75",
"strong": "#FFFFFF",
"buttonText": "#0F1419"
},
"background": {
"default": "#18232E",
"input": "#212D39",
"default": "#1C1C1C",
"input": "#26292C",
"tipMask": "rgba(255, 255, 255, 0.85)",
"messageShadow": "rgba(136, 153, 166, 0.2)"
"messageShadow": "rgba(136, 153, 166, 0.2)",
"paper": "#101010",
"modalTitle": "linear-gradient(180deg, #202020 0%, #181818 100%)"
},
"error": {
"main": "#FF5555"
Expand All @@ -94,11 +139,24 @@
"700": "#b8cbd9",
"300": "#92a4b3",
"200": "#697987",
"50": "#10171e"
"50": "#10171e",
"primary": "linear-gradient(0deg, rgba(245, 245, 245, 0.3), rgba(245, 245, 245, 0.3)), #000000",
"secondary": "linear-gradient(0deg, rgba(245, 245, 245, 0.1), rgba(245, 245, 245, 0.1)), #000000",
"third": "linear-gradient(0deg, rgba(245, 245, 245, 0.1), rgba(245, 245, 245, 0.1)), #000000"
},
"public": {
"primary": "#1C68F3",
"success": "#3DC233",
"warning": "#FFB100",
"danger": "#FF3545",
"white": "#ffffff",
"dark": "#07101B",
"secondaryDark": "#767F8D"
},
"text": {
"primary": "#EFF3F4",
"secondary": "#8899A6",
"primary": "#F5F5F5",
"secondary": "#C4C7CD",
"third": "#666C75",
"strong": "#FFFFFF",
"buttonText": "#0F1419"
},
Expand All @@ -108,75 +166,17 @@
"divider": "#38444D",
"secondaryDivider": "#38444D",
"background": {
"default": "#18232E",
"input": "#212D39",
"default": "#1C1C1C",
"input": "#26292C",
"tipMask": "rgba(255, 255, 255, 0.85)",
"messageShadow": "rgba(136, 153, 166, 0.2)"
"messageShadow": "rgba(136, 153, 166, 0.2)",
"paper": "#101010",
"modalTitle": "linear-gradient(180deg, #202020 0%, #181818 100%)"
},
"action": {
"buttonHover": "#D7DBDC",
"bgHover": "#1D2933",
"mask": "rgba(91, 112, 131, 0.4)"
}
},
"darker": {
"grey": {
"700": "#6e767d",
"300": "#3d4145",
"200": "#2f3336",
"50": "#202327"
},
"text": {
"primary": "#D9D9D9",
"secondary": "#6E767D",
"strong": "#EFF3F4",
"buttonText": "#0F1419"
},
"background": {
"default": "#15171A",
"input": "#1D2023",
"tipMask": "rgba(255, 255, 255, 0.85)",
"messageShadow": "rgba(255, 255, 255, 0.2)"
},
"error": {
"main": "#FF5555"
},
"divider": "#2F3336",
"secondaryDivider": "#2F3336",
"action": {
"buttonHover": "#D7dBDC",
"bgHover": "#1A1D20",
"mask": "rgba(91, 112, 131, 0.4)"
}
},
"darker_high_contrast": {
"grey": {
"700": "#929ca6",
"300": "#6e767d",
"200": "#3d4145",
"50": "#121517"
},
"text": {
"primary": "#D9D9D9",
"secondary": "#6E767D",
"strong": "#EFF3F4",
"buttonText": "#0F1419"
},
"error": {
"main": "#FF5555"
},
"divider": "#2F3336",
"secondaryDivider": "#2F3336",
"background": {
"default": "#15171A",
"input": "#1D2023",
"tipMask": "rgba(255, 255, 255, 0.85)",
"messageShadow": "rgba(255, 255, 255, 0.2)"
},
"action": {
"buttonHover": "#D7dBDC",
"bgHover": "#1A1D20",
"mask": "rgba(91, 112, 131, 0.4)"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const useInjectedDialogClassesOverwriteTwitter = makeStyles()((theme) => {
display: 'flex',
alignItems: 'center',
padding: '3px 16px',
borderBottom: `1px solid ${theme.palette.mode === 'dark' ? '#2f3336' : '#eff3f4'}`,
position: 'relative',
background: theme.palette.background.modalTitle,
borderBottom: 'none',
'& > h2': {
display: 'inline-block',
whiteSpace: 'nowrap',
Expand Down
19 changes: 19 additions & 0 deletions packages/mask/src/utils/theme/theme-global.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
declare module '@mui/material/styles/createPalette.d' {
export interface Palette {
secondaryDivider: string
public: {
primary: string
success: string
warning: string
danger: string
white: string
dark: string
secondaryDark: string
}
}
export interface TypeText {
third: string
hint: string
strong: string
buttonText: string
Expand All @@ -16,6 +26,15 @@ declare module '@mui/material/styles/createPalette.d' {
input: string
tipMask: string
messageShadow: string
modalTitle: string
}
}

declare module '@mui/material/index.d' {
export interface Color {
primary: string
second: string
third: string
}
}
export {}
16 changes: 16 additions & 0 deletions packages/mask/src/utils/theme/useClassicMaskSNSTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { createSubscriptionFromValueRef } from '@masknet/shared-base'
import { ValueRef } from '@dimensiondev/holoflows-kit'
import { useValueRef } from '@masknet/shared-base-ui'
import { languageSettings } from '../../settings/settings'
import { cloneDeep, merge } from 'lodash-unified'

const staticRef = createSubscriptionFromValueRef(new ValueRef('light'))
const defaultUseTheme = (t: Theme) => t
Expand All @@ -26,3 +27,18 @@ export function useClassicMaskSNSTheme() {
const theme = unstable_createMuiStrictModeTheme(baseTheme, localization)
return usePostTheme(theme)
}

export function useClassicMaskSNSPluginTheme() {
const theme = useClassicMaskSNSTheme()
return unstable_createMuiStrictModeTheme(
merge(cloneDeep(theme), {
components: {
MuiButton: {
defaultProps: {
variant: 'roundedContained',
},
},
},
}),
)
}
16 changes: 0 additions & 16 deletions packages/mask/src/utils/theme/useSwapPageTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,6 @@ export function useSwapPageTheme() {
variant: 'contained',
},
variants: [
{
props: { variant: 'sns' },
style: {
backgroundColor: theme.palette.primary.main,
color: theme.palette.common.white,
'&:hover': {
backgroundColor: theme.palette.primary.dark,
color: theme.palette.common.white,
},
'&.Mui-disabled': {
opacity: 0.5,
backgroundColor: theme.palette.primary.main,
color: theme.palette.common.white,
},
},
},
{
props: { color: 'error' },
style: {
Expand Down
Loading