-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
refactor: improve stage-web color palette settings readability #1671
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
Changes from 6 commits
84538ad
c5215a4
79bfe79
d172ab5
eb5b02c
d02ab3a
b41af13
c0e7b7f
aa57016
c025a50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,26 +40,15 @@ const cardStore = useAiriCardStore() | |
| const analyticsStore = useSharedAnalyticsStore() | ||
| const inferencePreload = useInferencePreload() | ||
|
|
||
| const primaryColor = computed(() => { | ||
| return isDark.value | ||
| ? `color-mix(in srgb, oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + ${0})) 70%, oklch(50% 0 360))` | ||
| : `color-mix(in srgb, oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + ${0})) 90%, oklch(90% 0 360))` | ||
| }) | ||
|
|
||
| const secondaryColor = computed(() => { | ||
| return isDark.value | ||
| ? `color-mix(in srgb, oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + ${180})) 70%, oklch(50% 0 360))` | ||
| : `color-mix(in srgb, oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + ${180})) 90%, oklch(90% 0 360))` | ||
| }) | ||
|
|
||
| const tertiaryColor = computed(() => { | ||
| return isDark.value | ||
| ? `color-mix(in srgb, oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + ${60})) 70%, oklch(50% 0 360))` | ||
| : `color-mix(in srgb, oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + ${60})) 90%, oklch(90% 0 360))` | ||
| }) | ||
| const getCSSVar = (variableName: string) => getComputedStyle(document.documentElement).getPropertyValue(variableName).trim() | ||
|
|
||
| const colors = computed(() => { | ||
| return [primaryColor.value, secondaryColor.value, tertiaryColor.value, isDark.value ? '#121212' : '#FFFFFF'] | ||
| return [ | ||
| getCSSVar('--primary-color'), | ||
|
drHuangMHT marked this conversation as resolved.
|
||
| getCSSVar('--secondary-color'), | ||
| getCSSVar('--tertiary-color'), | ||
|
drHuangMHT marked this conversation as resolved.
Comment on lines
+50
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This computed now snapshots resolved CSS colors via Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. who would ever want an interface with flashy RGB effects🤦 does the original code also watch this change? @codex
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the css variable returns what's in |
||
| isDark.value ? '#121212' : '#FFFFFF', | ||
| ] | ||
| }) | ||
|
drHuangMHT marked this conversation as resolved.
|
||
|
|
||
| const onboardingExtraSteps = computed(() => { | ||
|
|
@@ -119,9 +108,6 @@ function handleSetupSkipped() { | |
|
|
||
| <template> | ||
| <StageTransitionGroup | ||
| :primary-color="primaryColor" | ||
| :secondary-color="secondaryColor" | ||
| :tertiary-color="tertiaryColor" | ||
| :colors="colors" | ||
| :z-index="100" | ||
| :disable-transitions="settings.disableTransitions.value" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| :root { | ||
| /* Light mode defaults */ | ||
| --chromatic-hue: 0; | ||
| --chromatic-chroma-900: 0.15; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is controlled and injected by https://github.com/proj-airi/chromatic. We should not define this here. |
||
| --is-dark: 0; | ||
|
|
||
| --primary-color: color-mix( | ||
| in srgb, | ||
| oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + 0)) 90%, | ||
| oklch(90% 0 360) | ||
| ); | ||
|
|
||
| --secondary-color: color-mix( | ||
| in srgb, | ||
| oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + 180)) 90%, | ||
| oklch(90% 0 360) | ||
| ); | ||
|
|
||
| --tertiary-color: color-mix( | ||
| in srgb, | ||
| oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + 60)) 90%, | ||
| oklch(90% 0 360) | ||
| ); | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| :root { | ||
|
drHuangMHT marked this conversation as resolved.
|
||
| --is-dark: 1; | ||
|
|
||
| --primary-color: color-mix( | ||
| in srgb, | ||
| oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + 0)) 70%, | ||
| oklch(50% 0 360) | ||
| ); | ||
|
|
||
| --secondary-color: color-mix( | ||
| in srgb, | ||
| oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + 180)) 70%, | ||
| oklch(50% 0 360) | ||
| ); | ||
|
|
||
| --tertiary-color: color-mix( | ||
| in srgb, | ||
| oklch(95% var(--chromatic-chroma-900) calc(var(--chromatic-hue) + 60)) 70%, | ||
| oklch(50% 0 360) | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,22 @@ | ||
| <script setup lang="ts"> | ||
| import { computed, onMounted } from 'vue' | ||
| import type { StageTransitionCommonParams } from '.' | ||
|
|
||
| const props = withDefaults(defineProps<{ | ||
| stageTransition?: { | ||
| primaryColor?: string | ||
| secondaryColor?: string | ||
| zIndex?: number | ||
| } | ||
| }>(), { | ||
| stageTransition: () => ({ | ||
| primaryColor: '#666', | ||
| secondaryColor: '#ccc', | ||
| }), | ||
| }) | ||
| import { useCssVariables } from './useCssVar' | ||
|
|
||
| const stageTransition = computed(() => props.stageTransition) | ||
| const overlayColor1 = computed(() => stageTransition.value.primaryColor || '#666') | ||
| const overlayColor2 = computed(() => stageTransition.value.secondaryColor || '#ccc') | ||
| const { | ||
| primaryColor = '#666', | ||
| secondaryColor = '#ccc', | ||
| zIndex = 100, | ||
| } = defineProps<Omit<StageTransitionCommonParams, 'name'>>() | ||
|
Comment on lines
+6
to
+10
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are using vue |
||
|
|
||
| onMounted(() => { | ||
| document.documentElement.style.setProperty('--stage-transition-3-overlay-color-1', overlayColor1.value) | ||
| document.documentElement.style.setProperty('--stage-transition-3-overlay-color-2', overlayColor2.value) | ||
| }) | ||
| useCssVariables(() => ({ | ||
| 'overlay-color-1': primaryColor, | ||
| 'overlay-color-2': secondaryColor, | ||
| }), { prefix: '--stage-transition-3-' }) | ||
|
Comment on lines
+12
to
+15
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. improve code readability. |
||
| </script> | ||
|
|
||
| <template> | ||
| <div class="stage-transition-3" :style="{ zIndex: stageTransition.zIndex || 100 }" /> | ||
| <div class="stage-transition-3" :style="{ zIndex }" /> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,36 @@ | ||
| <script setup lang="ts"> | ||
| import { computed, onMounted } from 'vue' | ||
| import { useCssVariables } from './useCssVar' | ||
|
|
||
| const props = defineProps<{ | ||
| stageTransition?: { | ||
| colors?: string[] | ||
| delay?: number | ||
| duration?: number | ||
| zIndex?: number | ||
| } | ||
| }>() | ||
| interface TransitionParams { | ||
| colors?: string[] | ||
| delay?: number | ||
| duration?: number | ||
| zIndex?: number | ||
| } | ||
|
|
||
| const colors = computed(() => props.stageTransition?.colors || ['#eee', '#ebcb8b', '#c56370', '#3f3b52']) | ||
| const { | ||
| colors = ['#eee', '#ebcb8b', '#c56370', '#3f3b52'], | ||
| delay = 0, | ||
| duration = 0.4, | ||
| zIndex = 100, | ||
| } = defineProps<TransitionParams>() | ||
|
Comment on lines
+11
to
+16
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. withDefaults should be used as https://vuejs.org/guide/typescript/composition-api.html#props-default-values explained. |
||
|
|
||
| onMounted(() => { | ||
| document.documentElement.style.setProperty('--circle-expansion-delay', `${props.stageTransition?.delay || 0}s`) | ||
| document.documentElement.style.setProperty('--circle-expansion-duration', `${props.stageTransition?.duration || 0.4}s`) | ||
| colors.value.forEach((color, index) => { | ||
| document.documentElement.style.setProperty(`--circle-expansion-color-${index + 1}`, color) | ||
| function getCssVar() { | ||
| const record: Record<string, string> = { | ||
| delay: `${delay}s`, | ||
| duration: `${duration}s`, | ||
| } | ||
| colors.forEach((color, index) => { | ||
| record[`color-${index + 1}`] = color | ||
| }) | ||
| }) | ||
| return record | ||
| } | ||
|
|
||
| useCssVariables(getCssVar, { prefix: '--circle-expansion-' }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="circle-expansion-transition" :style="{ zIndex: stageTransition?.zIndex || 100 }"> | ||
| <div class="circle-expansion-transition" :style="{ zIndex }"> | ||
| <div v-for="(_, index) in colors" :key="index" /> | ||
| </div> | ||
| </template> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,47 @@ | ||
| <script setup lang="ts"> | ||
| import { computed, onMounted } from 'vue' | ||
|
|
||
| const props = defineProps <{ | ||
| stageTransition?: { | ||
| primaryColor?: string | ||
| duration?: number | ||
| delay?: number | ||
| direction?: 'up' | 'down' | 'left' | 'right' | ||
| borderRadius?: { | ||
| sm?: string | ||
| md?: string | ||
| lg?: string | ||
| } | ||
| zIndex?: number | ||
| } | ||
| }>() | ||
|
|
||
| const direction = computed(() => props.stageTransition?.direction || 'up') | ||
| const directionClass = computed(() => `fantasy-fall-${direction.value}`) | ||
|
|
||
| onMounted(() => { | ||
| document.documentElement.style.setProperty('--fantasy-fall-color', props.stageTransition?.primaryColor || '#eee') | ||
| document.documentElement.style.setProperty('--fantasy-fall-duration', `${props.stageTransition?.duration || 0.6}s`) | ||
| document.documentElement.style.setProperty('--fantasy-fall-delay', `${props.stageTransition?.delay || 0}s`) | ||
| document.documentElement.style.setProperty('--fantasy-fall-radius-sm', `${props.stageTransition?.borderRadius?.sm || '14rem'}`) | ||
| document.documentElement.style.setProperty('--fantasy-fall-radius-md', `${props.stageTransition?.borderRadius?.md || '14rem'}`) | ||
| document.documentElement.style.setProperty('--fantasy-fall-radius-lg', `${props.stageTransition?.borderRadius?.lg || '50%'}`) | ||
| }) | ||
| import { computed } from 'vue' | ||
|
|
||
| import { useCssVariables } from './useCssVar' | ||
|
|
||
| interface TransitionParams { | ||
| primaryColor?: string | ||
| duration?: number | ||
| delay?: number | ||
| direction?: 'up' | 'down' | 'left' | 'right' | ||
| borderRadius?: { | ||
| sm?: string | ||
| md?: string | ||
| lg?: string | ||
| } | ||
| zIndex?: number | ||
| } | ||
|
|
||
| const { | ||
| direction = 'up', | ||
| primaryColor = '#eee', | ||
| duration = 0.6, | ||
| delay = 0, | ||
| borderRadius = { sm: '14rem', md: '14rem', lg: '50%' }, | ||
| zIndex = 100, | ||
| } = defineProps<TransitionParams>() | ||
|
Comment on lines
+19
to
+26
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. withDefaults should be used as https://vuejs.org/guide/typescript/composition-api.html#props-default-values explained. |
||
| const directionClass = computed(() => `fantasy-fall-${direction}`) | ||
|
|
||
| useCssVariables(() => ({ | ||
| 'color': primaryColor, | ||
| 'duration': `${duration}s`, | ||
| 'delay': `${delay}s`, | ||
| 'radius-sm': borderRadius?.sm ?? '14rem', | ||
| 'radius-md': borderRadius?.md ?? '14rem', | ||
| 'radius-lg': borderRadius?.lg ?? '50%', | ||
| }), { prefix: '--fantasy-fall-' }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="fantasy-fall-transition" :class="directionClass" :style="{ zIndex: stageTransition?.zIndex ?? 100 }" /> | ||
| <div | ||
| class="fantasy-fall-transition" | ||
| :class="directionClass" | ||
| :style="{ zIndex }" | ||
| /> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
|
|
@@ -53,7 +64,8 @@ onMounted(() => { | |
| transform: translateY(-100%); | ||
| border-bottom-left-radius: var(--fantasy-fall-radius-sm); | ||
| border-bottom-right-radius: var(--fantasy-fall-radius-sm); | ||
| animation: fantasy-fall-up var(--fantasy-fall-duration) ease-out var(--fantasy-fall-delay) forwards; | ||
| animation: fantasy-fall-up var(--fantasy-fall-duration) ease-out | ||
| var(--fantasy-fall-delay) forwards; | ||
| } | ||
|
|
||
| /* Bottom direction */ | ||
|
|
@@ -69,7 +81,8 @@ onMounted(() => { | |
| transform: translateY(100%); | ||
| border-top-left-radius: var(--fantasy-fall-radius-sm); | ||
| border-top-right-radius: var(--fantasy-fall-radius-sm); | ||
| animation: fantasy-fall-down var(--fantasy-fall-duration) ease-out var(--fantasy-fall-delay) forwards; | ||
| animation: fantasy-fall-down var(--fantasy-fall-duration) ease-out | ||
| var(--fantasy-fall-delay) forwards; | ||
| } | ||
|
|
||
| /* Left direction */ | ||
|
|
@@ -85,7 +98,8 @@ onMounted(() => { | |
| transform: translateX(-100%); | ||
| border-top-right-radius: var(--fantasy-fall-radius-sm); | ||
| border-bottom-right-radius: var(--fantasy-fall-radius-sm); | ||
| animation: fantasy-fall-left var(--fantasy-fall-duration) ease-out var(--fantasy-fall-delay) forwards; | ||
| animation: fantasy-fall-left var(--fantasy-fall-duration) ease-out | ||
| var(--fantasy-fall-delay) forwards; | ||
| } | ||
|
|
||
| /* Right direction */ | ||
|
|
@@ -101,7 +115,8 @@ onMounted(() => { | |
| transform: translateX(100%); | ||
| border-top-left-radius: var(--fantasy-fall-radius-sm); | ||
| border-bottom-left-radius: var(--fantasy-fall-radius-sm); | ||
| animation: fantasy-fall-right var(--fantasy-fall-duration) ease-out var(--fantasy-fall-delay) forwards; | ||
| animation: fantasy-fall-right var(--fantasy-fall-duration) ease-out | ||
| var(--fantasy-fall-delay) forwards; | ||
| } | ||
|
|
||
| /* Responsive border radius adjustments */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be replaced with the new https://github.com/proj-airi/chromatic/blob/3be1f5990069fa5dd006ae314c979ef54906d1e5/packages/chromatic/src/index.ts#L148-L198