Skip to content

refactor: improve stage-web color palette settings readability#1671

Closed
drHuangMHT wants to merge 10 commits intomoeru-ai:mainfrom
drHuangMHT:stage-web-color-palette
Closed

refactor: improve stage-web color palette settings readability#1671
drHuangMHT wants to merge 10 commits intomoeru-ai:mainfrom
drHuangMHT:stage-web-color-palette

Conversation

@drHuangMHT
Copy link
Copy Markdown
Contributor

Description

Improve code readability:

  • compute primary, secondary, and tertiary color in CSS instead of JavaScript. also handles dark mode with media query
  • improve StageTransition component prop readability with prop destructing and defaults
  • improve readability when setting CSS variables in transition components, using useCssVariables composable(with proper tests, and some features!)

packages introduced:

  • @vue/test-utils and jsdom for running tests(dev dependency)

Linked Issues

Additional Context

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request centralizes transition colors using CSS variables and introduces a useCssVariables composable with accompanying unit tests. Feedback highlights a reactivity bug in App.vue where colors may become stale when the theme hue changes. Significant logic and compatibility issues were identified in the useCssVariables composable regarding target cleanup and ES2024 features, and corrections to the JSDoc examples were suggested to ensure type safety and maintain reactivity.

Comment thread apps/stage-web/src/App.vue
Comment thread packages/ui-transitions/src/components/useCssVar.ts
Comment thread packages/ui-transitions/src/components/useCssVar.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d02ab3a7ea

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/stage-web/src/App.vue
Comment thread apps/stage-web/src/App.vue
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c025a503b1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/stage-web/src/styles/colors.css
Comment on lines +50 to +52
getCSSVar('--primary-color'),
getCSSVar('--secondary-color'),
getCSSVar('--tertiary-color'),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep transition colors reactive during dynamic hue animation

This computed now snapshots resolved CSS colors via getComputedStyle(...), so it only updates when tracked refs change; however dynamic hue mode animates --chromatic-hue in CSS (.dynamic-hue) without changing settings.themeColorsHue. As a result, when dynamic hue is enabled, transitions use stale sampled colors instead of tracking the live hue animation that the previous color-expression approach provided.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

@drHuangMHT drHuangMHT Apr 16, 2026

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the css variable returns what's in colors.css as raw value that is not mixed into RGB value, which is static. this is not an issue as long as the variable is used in styles. CSS engine will handle the update automatically.

@nekomeowww
Copy link
Copy Markdown
Member

What is the purpose of this PR?

If you need to adjust the color, perhaps reading https://proj-airi-chromatic.netlify.app/

@nekomeowww
Copy link
Copy Markdown
Member

If possible, submit more screenshots, explaining why this is necessary, then re-open another PR if needed.

@nekomeowww nekomeowww closed this Apr 17, 2026
@drHuangMHT
Copy link
Copy Markdown
Contributor Author

drHuangMHT commented Apr 17, 2026

If possible, submit more screenshots, explaining why this is necessary, then re-open another PR if needed.

I don't think screenshots are necessary because the code does not involve changes to the visual appearance of the application. I'm just trying to organize the code for readability. It's about the program code, about the developer experience, not the appearance of the application, not the color-mixing algorithms.

@drHuangMHT
Copy link
Copy Markdown
Contributor Author

@nekomeowww not re-opening this one?

:root {
/* Light mode defaults */
--chromatic-hue: 0;
--chromatic-chroma-900: 0.15;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Comment on lines -43 to -59
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))`
})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +6 to +10
const {
primaryColor = '#666',
secondaryColor = '#ccc',
zIndex = 100,
} = defineProps<Omit<StageTransitionCommonParams, 'name'>>()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using vue ^3.5.32 according to the catalog, and reactive props destructure is available. not using it?

*/
export function useCssVariables(
variableGetter: MaybeRefOrGetter<Record<string, string | undefined>>,
options?: { elementGetter?: MaybeRefOrGetter<HTMLElement | null>, prefix?: string },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options?: { elementGetter?: MaybeRefOrGetter<HTMLElement | null>, prefix?: string },
options?: { target?: MaybeRefOrGetter<HTMLElement | null>, prefix?: string },

Comment on lines +12 to +15
useCssVariables(() => ({
'overlay-color-1': primaryColor,
'overlay-color-2': secondaryColor,
}), { prefix: '--stage-transition-3-' })
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improve code readability. useCssVariables also handles reactivity when you need it(although not needed in this case).

Comment on lines +11 to +16
const {
colors = ['#eee', '#ebcb8b', '#c56370', '#3f3b52'],
delay = 0,
duration = 0.4,
zIndex = 100,
} = defineProps<TransitionParams>()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +19 to +26
const {
direction = 'up',
primaryColor = '#eee',
duration = 0.6,
delay = 0,
borderRadius = { sm: '14rem', md: '14rem', lg: '50%' },
zIndex = 100,
} = defineProps<TransitionParams>()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants