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

style(glow-effect): add darkmode colors #190

Merged
merged 1 commit into from
Dec 1, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ const AvatarLayout: FC<TProps> = ({ layout, isTouched, saving }) => {
isTouched={isTouched}
field={SETTING_FIELD.AVATAR_LAYOUT}
loading={saving}
width="80%"
width="580px"
left={-5}
top={25}
/>
</Wrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ const BannerLayout: FC<TProps> = ({ layout, isTouched, saving }) => {
isTouched={isTouched}
field={SETTING_FIELD.BANNER_LAYOUT}
loading={saving}
width="88%"
width="632px"
left={-5}
top={20}
/>
</Wrapper>
Expand Down
13 changes: 7 additions & 6 deletions src/containers/thread/DashboardThread/Layout/GlowEffect.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FC } from 'react'
import { observer } from 'mobx-react-lite'
import { keys } from 'ramda'

import GLOW_EFFECTS, { GLOW_OPACITY } from '@/constant/glow_effect'
import { GLOW_OPACITY, GLOW_EFFECTS_KEYS } from '@/constant/glow_effect'
import usePrimaryColor from '@/hooks/usePrimaryColor'
import useTheme from '@/hooks/useTheme'

import { Br, Row as RowBase } from '@/widgets/Common'
import ArrowLinker from '@/widgets/ArrowLinker'
Expand Down Expand Up @@ -47,7 +47,7 @@ const GlowEffect: FC<TProps> = ({
saving,
}) => {
const primaryColor = usePrimaryColor()
const EFFECTS_KEYS = keys(GLOW_EFFECTS)
const { curTheme } = useTheme()

return (
<Wrapper>
Expand All @@ -69,14 +69,14 @@ const GlowEffect: FC<TProps> = ({
<CloseIcon />
</NoBox>

{EFFECTS_KEYS.map((effect) => (
{GLOW_EFFECTS_KEYS.map((effect) => (
<Box
key={effect}
$active={effect === glowType}
$color={primaryColor}
onClick={() => edit(effect, 'glowType')}
>
<GrowBackground glowPosition="absolute" glowType={effect} />
<GrowBackground glowPosition="absolute" glowType={effect} $curTheme={curTheme} />
</Box>
))}
</Row>
Expand All @@ -85,8 +85,9 @@ const GlowEffect: FC<TProps> = ({
isTouched={isTouched}
field={SETTING_FIELD.GLOW_TYPE}
loading={saving}
left={-5}
top={35}
width="87%"
width="628px"
/>

<Br bottom={40} />
Expand Down
3 changes: 2 additions & 1 deletion src/containers/thread/DashboardThread/Layout/TagLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const TagLayout: FC<TProps> = ({ layout, isTouched, saving }) => {
isTouched={isTouched}
field={SETTING_FIELD.TAG_LAYOUT}
loading={saving}
width="80%"
left={-5}
width="580px"
top={25}
/>
</Wrapper>
Expand Down
1 change: 0 additions & 1 deletion src/containers/thread/DashboardThread/store/Models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export const settingsModalFields = {
docCategories: T.opt(T.array(GroupCategory), []),

// glow effect
// glowType: T.opt(T.string, keys(GLOW_EFFECTS)[0]),
glowType: T.opt(T.string, ''),
glowFixed: T.opt(T.bool, true),
glowOpacity: T.opt(T.enum(values(GLOW_OPACITY)), GLOW_OPACITY.NORMAL),
Expand Down
14 changes: 10 additions & 4 deletions src/containers/thread/DashboardThread/styles/layout/glow_effect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import styled from 'styled-components'

import type { TActive, TColor, TGlowEffect } from '@/spec'
import GLOW_EFFECTS from '@/constant/glow_effect'
import { GLOW_EFFECTS_DAY, GLOW_EFFECTS_NIGHT } from '@/constant/glow_effect'
import THEME from '@/constant/theme'

import css, { theme, rainbow } from '@/css'

Expand Down Expand Up @@ -31,7 +32,8 @@ export const Box = styled.div<TBox>`
border: 1px solid;
z-index: 1;

border-color: ${({ $active, $color }) => ($active ? rainbow($color) : theme('divider'))};
border-color: ${({ $active, $color }) =>
$active ? rainbow($color, 'article.digest') : theme('divider')};

box-shadow: ${({ $active }) => ($active ? css.cardShadow : 'none')};
background: ${theme('alphaBg')};
Expand Down Expand Up @@ -71,12 +73,16 @@ export const SettingsRow = styled.div`
export const GrowBackground = styled('div').withConfig({
shouldForwardProp: (props) => props !== 'glowType' && props !== 'glowPosition',
})<TGlowEffect>`
background: ${({ glowType }) => `
background: ${({ glowType, $curTheme }) => {
const GLOW_EFFECTS = $curTheme === THEME.DAY ? GLOW_EFFECTS_DAY : GLOW_EFFECTS_NIGHT

return `
radial-gradient(circle at ${GLOW_EFFECTS[glowType].LEFT.X} ${GLOW_EFFECTS[glowType].LEFT.Y}, ${GLOW_EFFECTS[glowType].LEFT.COLOR} 0, transparent ${GLOW_EFFECTS[glowType].LEFT.RADIUS}),
radial-gradient(circle at ${GLOW_EFFECTS[glowType].RIGHT1.X} ${GLOW_EFFECTS[glowType].RIGHT1.Y}, ${GLOW_EFFECTS[glowType].RIGHT1.COLOR} 0, transparent ${GLOW_EFFECTS[glowType].RIGHT1.RADIUS}),
radial-gradient(circle at ${GLOW_EFFECTS[glowType].MAIN.X} ${GLOW_EFFECTS[glowType].MAIN.Y}, ${GLOW_EFFECTS[glowType].MAIN.COLOR} 0, transparent ${GLOW_EFFECTS[glowType].MAIN.RADIUS}),
radial-gradient(circle at ${GLOW_EFFECTS[glowType].RIGHT2.X} ${GLOW_EFFECTS[glowType].RIGHT2.Y}, ${GLOW_EFFECTS[glowType].RIGHT2.COLOR} 0, transparent ${GLOW_EFFECTS[glowType].RIGHT1.RADIUS});
`};
`
}};

filter: saturate(1.2);
inset: 0;
Expand Down
6 changes: 1 addition & 5 deletions src/containers/thread/DashboardThread/styles/layout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const Wrapper = styled.div`
padding: 20px;
`};
`

export const Banner = styled.div`
height: 70px;
width: 100%;
Expand All @@ -35,10 +34,7 @@ export const TabsWrapper = styled.div`
`};
`
export const BaseSection = styled.section`
/* margin: 0 50px; */
padding-bottom: 30px;
/* border-bottom: 1px solid;
border-bottom-color: ${theme('divider')}; */
`
export const TitleBase = styled.div`
color: ${theme('article.title')};
Expand All @@ -55,7 +51,7 @@ export const BlockBase = styled.div<TBlockBase>`

border: 1px solid;
border-radius: 7px;
border-color: ${({ $active, $color }) => ($active ? rainbow($color) : theme('primary'))};
border-color: ${({ $active, $color }) => ($active ? rainbow($color, 'hint') : theme('primary'))};
padding: 16px 15px;

&:hover {
Expand Down
3 changes: 2 additions & 1 deletion src/spec/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable import/no-unresolved */
/* eslint-disable import/extensions */

import type { TRootStore as RootStoreType } from '@/stores/RootStore'

import type { TThemeName } from './theme'
import type { TArticle } from './article'
import type { TCommunity } from './community'

Expand Down Expand Up @@ -216,6 +216,7 @@ export type TGlowEffect = {
glowPosition?: TGlowPosition
glowFixed?: boolean
glowOpacity?: string
$curTheme?: TThemeName
}

interface IWindow extends Window {
Expand Down
3 changes: 3 additions & 0 deletions src/widgets/GlobalLayout/GlowBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { TMetric, TGlowPosition } from '@/spec'

import useGlow from '@/hooks/useGlow'
import useMetric from '@/hooks/useMetric'
import useTheme from '@/hooks/useTheme'

import METRIC from '@/constant/metric'

Expand All @@ -19,6 +20,7 @@ const getGlowPosition = (metric: TMetric, glowFixed: boolean): TGlowPosition =>

const GlowBackground: FC = () => {
const metric = useMetric()
const { curTheme } = useTheme()
const { glowType, glowFixed, glowOpacity } = useGlow()

if (!glowType) return null
Expand All @@ -28,6 +30,7 @@ const GlowBackground: FC = () => {
glowType={glowType}
glowPosition={getGlowPosition(metric, glowFixed)}
glowOpacity={glowOpacity}
$curTheme={curTheme}
/>
)
}
Expand Down
10 changes: 7 additions & 3 deletions src/widgets/GlobalLayout/styles/glow_background.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import styled from 'styled-components'

import type { TGlowEffect } from '@/spec'
import GLOW_EFFECTS from '@/constant/glow_effect'
import { GLOW_EFFECTS_DAY, GLOW_EFFECTS_NIGHT } from '@/constant/glow_effect'
import THEME from '@/constant/theme'

export const Wrapper = styled('div').withConfig({
shouldForwardProp: (props) =>
props !== 'glowType' && props !== 'glowPosition' && props !== 'glowOpacity',
})<TGlowEffect>`
background: ${({ glowType }) => `
background: ${({ glowType, $curTheme }) => {
const GLOW_EFFECTS = $curTheme === THEME.DAY ? GLOW_EFFECTS_DAY : GLOW_EFFECTS_NIGHT
return `
radial-gradient(circle at ${GLOW_EFFECTS[glowType].LEFT.X} ${GLOW_EFFECTS[glowType].LEFT.Y}, ${GLOW_EFFECTS[glowType].LEFT.COLOR} 0, transparent ${GLOW_EFFECTS[glowType].LEFT.RADIUS}),
radial-gradient(circle at ${GLOW_EFFECTS[glowType].RIGHT1.X} ${GLOW_EFFECTS[glowType].RIGHT1.Y}, ${GLOW_EFFECTS[glowType].RIGHT1.COLOR} 0, transparent ${GLOW_EFFECTS[glowType].RIGHT1.RADIUS}),
radial-gradient(circle at ${GLOW_EFFECTS[glowType].MAIN.X} ${GLOW_EFFECTS[glowType].MAIN.Y}, ${GLOW_EFFECTS[glowType].MAIN.COLOR} 0, transparent ${GLOW_EFFECTS[glowType].MAIN.RADIUS}),
radial-gradient(circle at ${GLOW_EFFECTS[glowType].RIGHT2.X} ${GLOW_EFFECTS[glowType].RIGHT2.Y}, ${GLOW_EFFECTS[glowType].RIGHT2.COLOR} 0, transparent ${GLOW_EFFECTS[glowType].RIGHT1.RADIUS});
`};
`
}};

filter: saturate(1.2);

Expand Down
141 changes: 139 additions & 2 deletions utils/constant/glow_effect.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { keys } from 'ramda'

export const GLOW_OPACITY = {
NORMAL: '1',
WEEK: '0.68',
Expand All @@ -11,7 +13,7 @@ export const GLOW_EFFECT_NAME = {
PURPLE_BLUE: 'PURPLE_BLUE',
}

const GLOW_EFFECTS = {
export const GLOW_EFFECTS_DAY = {
ORANGE_PURPLE: {
LEFT: {
COLOR: '#f39e8d26',
Expand Down Expand Up @@ -146,4 +148,139 @@ const GLOW_EFFECTS = {
},
}

export default GLOW_EFFECTS
export const GLOW_EFFECTS_NIGHT = {
ORANGE_PURPLE: {
LEFT: {
COLOR: '#f39e8d26',
X: '25%',
Y: '-16%',
RADIUS: '30%',
},
RIGHT1: {
COLOR: '#ffeba824',
X: '100%',
Y: '0',
RADIUS: '40%',
},
MAIN: {
COLOR: '#4e4bd212',
X: '78%',
Y: '4%',
RADIUS: '40%',
},
RIGHT2: {
COLOR: '#961fb314',
X: '90%',
Y: '15%',
RADIUS: '30%',
},
},
GREY_BROWN: {
LEFT: {
COLOR: '#5f564c8a',
X: '20%',
Y: '-16%',
RADIUS: '30%',
},
RIGHT1: {
COLOR: '#d4003f03',
X: '100%',
Y: '0',
RADIUS: '40%',
},

MAIN: {
COLOR: '#ff980012',
X: '72%',
Y: '4%',
RADIUS: '40%',
},
RIGHT2: {
COLOR: '#f6c49f1c',
X: '80%',
Y: '18%',
RADIUS: '30%',
},
},
YELLOW_RED: {
LEFT: {
COLOR: '#ffc43b2b',
X: '20%',
Y: '-16%',
RADIUS: '30%',
},
RIGHT1: {
COLOR: '#d4003f03',
X: '100%',
Y: '0',
RADIUS: '40%',
},

MAIN: {
COLOR: '#f4433621',
X: '78%',
Y: '4%',
RADIUS: '40%',
},
RIGHT2: {
COLOR: '#ff98000a',
X: '90%',
Y: '15%',
RADIUS: '30%',
},
},
GREY_GREEN: {
LEFT: {
COLOR: '#444b428a',
X: '30%',
Y: '-16%',
RADIUS: '30%',
},
RIGHT1: {
COLOR: '#30381fa6',
X: '100%',
Y: '0',
RADIUS: '40%',
},
MAIN: {
COLOR: '#2e3323a6',
X: '78%',
Y: '4%',
RADIUS: '40%',
},
RIGHT2: {
COLOR: '#363c2978',
X: '90%',
Y: '15%',
RADIUS: '30%',
},
},
PURPLE_BLUE: {
LEFT: {
COLOR: '#323d498f',
X: '28%',
Y: '-8%',
RADIUS: '26%',
},
RIGHT1: {
COLOR: '#2b36489e',
X: '100%',
Y: '0',
RADIUS: '40%',
},
MAIN: {
COLOR: '#12283c59',
X: '70%',
Y: '4%',
RADIUS: '35%',
},
RIGHT2: {
COLOR: '#0e2b4670',
X: '85%',
Y: '15%',
RADIUS: '30%',
},
},
}

export const GLOW_EFFECTS_KEYS = keys(GLOW_EFFECTS_DAY)
Loading