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

Chore(Types): move duplicate types to theme [WUI-110] #2684

Merged
merged 11 commits into from
Feb 20, 2025

Conversation

Isaacmaamouche
Copy link
Contributor

DESCRIPTION

  • Removes duplicate type and import them from theme when they're used in multiple places
  • Exports a new type ThemeColorTokens for all our colors name
  • Introduces a new type util LiteralUnion
    LiteralUnion<T, U = string> = T | (U & Record<never, never>)

Preserve type intellisence and autocomplete on union with string

// The following type:
type color = 'red' | 'blue' | 'green' | string
// would be interpreted as 
type color = string
// and provide no autocompletion

With the new util LiteralUnion<T, U> you can pass your type as T and you union target as U (default to string)

// The following type:
type color = LiteralUnion<'red' | 'blue' | 'green'>
// would be interpreted as 
type color = 'red' | 'blue' | 'green'
// While still allowing any literal string without error
 * const bg: color = 'yellow'
 * const bg: color = '#FFF'

Works with number as well

type LoarderSize = 'xs' | 'sm' | 'md' | 'lg'
export type Size = LiteralUnion<LoarderSize, string | number>

@Isaacmaamouche Isaacmaamouche requested a review from a team as a code owner February 14, 2025 14:22
Copy link

linear bot commented Feb 14, 2025

Copy link

👀 Visit Preview

Copy link
Contributor

@anucreative anucreative left a comment

Choose a reason for hiding this comment

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

Très propre ! 👏🏼

Copy link
Contributor

@theo-mesnil theo-mesnil left a comment

Choose a reason for hiding this comment

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

👏🏻

@theo-mesnil theo-mesnil merged commit e610783 into main Feb 20, 2025
10 checks passed
@theo-mesnil theo-mesnil deleted the WUI-110-chore-move-types-to-theme branch February 20, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants