Skip to content
Open
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
36 changes: 36 additions & 0 deletions src/components/__tests__/__snapshots__/ListSection.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ exports[`renders list section with custom title style 1`] = `
},
},
"roundness": 4,
"shapes": {
"extraExtraLarge": 48,
"extraLarge": 28,
"extraLargeIncreased": 32,
"extraSmall": 4,
"full": 9999,
"large": 16,
"largeIncreased": 20,
"medium": 12,
"none": 0,
"small": 8,
},
"state": {
"opacity": {
"dragged": 0.16,
Expand Down Expand Up @@ -738,6 +750,18 @@ exports[`renders list section with subheader 1`] = `
},
},
"roundness": 4,
"shapes": {
"extraExtraLarge": 48,
"extraLarge": 28,
"extraLargeIncreased": 32,
"extraSmall": 4,
"full": 9999,
"large": 16,
"largeIncreased": 20,
"medium": 12,
"none": 0,
"small": 8,
},
"state": {
"opacity": {
"dragged": 0.16,
Expand Down Expand Up @@ -1286,6 +1310,18 @@ exports[`renders list section without subheader 1`] = `
},
},
"roundness": 4,
"shapes": {
"extraExtraLarge": 48,
"extraLarge": 28,
"extraLargeIncreased": 32,
"extraSmall": 4,
"full": 9999,
"large": 16,
"largeIncreased": 20,
"medium": 12,
"none": 0,
"small": 8,
},
"state": {
"opacity": {
"dragged": 0.16,
Expand Down
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export { default as Provider } from './core/PaperProvider';
export { default as PaperProvider } from './core/PaperProvider';
export { default as shadow } from './theme/shadow';
export { default as configureFonts } from './theme/fonts';
export { cornersToStyle } from './theme/tokens/sys/shape';
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.

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.


import * as Avatar from './components/Avatar/Avatar';
import * as Drawer from './components/Drawer/Drawer';
Expand Down
2 changes: 2 additions & 0 deletions src/theme/schemes/DarkTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { baseTheme } from './base';
import { tokens } from '../tokens';
import { buildScheme } from '../tokens/sys/color/roles';
import { defaultShapes } from '../tokens/sys/shape';
import { defaultState } from '../tokens/sys/state';
import type { Theme } from '../types';

Expand All @@ -10,4 +11,5 @@ export const DarkTheme: Theme = {
mode: 'adaptive',
colors: buildScheme(tokens.md.ref.palette, tokens.md.ref, { mode: 'dark' }),
state: defaultState,
shapes: defaultShapes,
};
2 changes: 2 additions & 0 deletions src/theme/schemes/LightTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { baseTheme } from './base';
import { tokens } from '../tokens';
import { buildScheme } from '../tokens/sys/color/roles';
import { defaultShapes } from '../tokens/sys/shape';
import { defaultState } from '../tokens/sys/state';
import type { Theme } from '../types';

Expand All @@ -9,4 +10,5 @@ export const LightTheme: Theme = {
dark: false,
colors: buildScheme(tokens.md.ref.palette, tokens.md.ref, { mode: 'light' }),
state: defaultState,
shapes: defaultShapes,
};
33 changes: 33 additions & 0 deletions src/theme/tokens/sys/shape.ts
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,
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.

Don't think it makes sense to expose none as a customizable theme value. It'll always be 0.

extraSmall: 4,
small: 8,
medium: 12,
large: 16,
largeIncreased: 20,
extraLarge: 28,
extraLargeIncreased: 32,
extraExtraLarge: 48,
full: 9999,
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.

Same as none. Don't think it makes sense to expose it as a customizable theme value.

};

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,
};
}
1 change: 1 addition & 0 deletions src/theme/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './color';
export * from './elevation';
export * from './navigation';
export * from './shape';
export * from './state';
export * from './theme';
export * from './typography';
Expand Down
19 changes: 19 additions & 0 deletions src/theme/types/shape.ts
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
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.

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;
};
3 changes: 3 additions & 0 deletions src/theme/types/theme.ts
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';

Expand All @@ -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
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.

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;
Expand All @@ -20,6 +22,7 @@ export type Theme = ThemeBase & {
colors: ThemeColors;
fonts: Typescale;
state: ThemeState;
shapes: ThemeShapes;
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.

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;
Expand Down
Loading