-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add theme.shapes and cornersToStyle #4919
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
base: @adrcotfas/refactor/tokens_state
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import type { ViewStyle } from 'react-native'; | ||
|
|
||
| import type { ShapeCorners, ThemeShapes } from '../../types'; | ||
|
|
||
| export const defaultShapes: ThemeShapes = { | ||
| none: 0, | ||
|
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. Don't think it makes sense to expose |
||
| extraSmall: 4, | ||
| small: 8, | ||
| medium: 12, | ||
| large: 16, | ||
| largeIncreased: 20, | ||
| extraLarge: 28, | ||
| extraLargeIncreased: 32, | ||
| extraExtraLarge: 48, | ||
| full: 9999, | ||
|
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. Same as |
||
| }; | ||
|
|
||
| type CornersStyle = Pick< | ||
| ViewStyle, | ||
| | 'borderTopStartRadius' | ||
| | 'borderTopEndRadius' | ||
| | 'borderBottomStartRadius' | ||
| | 'borderBottomEndRadius' | ||
| >; | ||
|
|
||
| export function cornersToStyle(corners: ShapeCorners): CornersStyle { | ||
| return { | ||
| borderTopStartRadius: corners.topStart, | ||
| borderTopEndRadius: corners.topEnd, | ||
| borderBottomStartRadius: corners.bottomStart, | ||
| borderBottomEndRadius: corners.bottomEnd, | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| export type ShapeCorners = { | ||
| topStart: number; | ||
| topEnd: number; | ||
| bottomStart: number; | ||
| bottomEnd: number; | ||
| }; | ||
|
Comment on lines
+1
to
+6
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. Not sure we need this. Isn't this just style properties? |
||
|
|
||
| export type ThemeShapes = { | ||
| none: number; | ||
| extraSmall: number; | ||
| small: number; | ||
| medium: number; | ||
| large: number; | ||
| largeIncreased: number; | ||
| extraLarge: number; | ||
| extraLargeIncreased: number; | ||
| extraExtraLarge: number; | ||
| full: number; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import type { $DeepPartial } from '@callstack/react-theme-provider'; | ||
|
|
||
| import type { ThemeColors } from './color'; | ||
| import type { ThemeShapes } from './shape'; | ||
| import type { ThemeState } from './state'; | ||
| import type { Typescale } from './typography'; | ||
|
|
||
|
|
@@ -9,6 +10,7 @@ type Mode = 'adaptive' | 'exact'; | |
| export type ThemeBase = { | ||
| dark: boolean; | ||
| mode?: Mode; | ||
| /** @deprecated Use `theme.shapes.*` instead. Will be removed in a future version. */ | ||
| roundness: number; | ||
|
Comment on lines
+13
to
14
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. Don't keep deprecated values in the theme. It makes things more complicated for components. If there is a replacement, drop the old one. |
||
| animation: { | ||
| scale: number; | ||
|
|
@@ -20,6 +22,7 @@ export type Theme = ThemeBase & { | |
| colors: ThemeColors; | ||
| fonts: Typescale; | ||
| state: ThemeState; | ||
| shapes: ThemeShapes; | ||
|
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. I'm not sure about the name "shapes". It says "shapes" but it exposes roundness/border radius values, not actual shapes, so the name is confusing. |
||
| }; | ||
|
|
||
| export type InternalTheme = Theme; | ||
|
|
||
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.
Don't expose such tiny utilities. Keep the library public API surface small. It's very straightforward for users to write such utility themselves, should they need it.