Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/components/Button/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { tokens } from '../../theme/tokens';
import type { InternalTheme, Theme } from '../../types';
import { splitStyles } from '../../utils/splitStyles';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

export type ButtonMode =
| 'text'
Expand Down
8 changes: 2 additions & 6 deletions src/components/Checkbox/CheckboxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

import Checkbox from './Checkbox';
import { useInternalTheme } from '../../core/theming';
import { tokens } from '../../theme/tokens';
import { getStateLayer } from '../../theme/utils/state';
import type { ThemeProp, TypescaleKey } from '../../types';
import TouchableRipple, {
Props as TouchableRippleProps,
Expand Down Expand Up @@ -145,14 +145,10 @@ const CheckboxItem = ({
const isLeading = position === 'leading';
const checkbox = <Checkbox {...checkboxProps} />;

const textColor = theme.colors.onSurface;
const textAlign = isLeading ? 'right' : 'left';

const computedStyle = {
color: textColor,
opacity: disabled
? tokens.md.ref.stateOpacity.disabled
: tokens.md.ref.stateOpacity.enabled,
...getStateLayer(theme, 'onSurface', disabled ? 'disabled' : 'enabled'),
textAlign,
} as TextStyle;

Expand Down
2 changes: 1 addition & 1 deletion src/components/Checkbox/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ColorValue } from 'react-native';
import { tokens } from '../../theme/tokens';
import type { InternalTheme } from '../../types';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

const getCheckedColor = ({
theme,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chip/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { InternalTheme, Theme } from '../../types';

const md3 = (theme: InternalTheme) => theme as Theme;

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

export type ChipAvatarProps = {
style?: StyleProp<ViewStyle>;
Expand Down
23 changes: 7 additions & 16 deletions src/components/HelperText/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { tokens } from '../../theme/tokens';
import { getStateLayer } from '../../theme/utils/state';
import type { InternalTheme } from '../../types';

const { stateOpacity } = tokens.md.ref;

type BaseProps = {
theme: InternalTheme;
disabled?: boolean;
Expand All @@ -11,18 +9,11 @@ type BaseProps = {

export function getTextColor({ theme, disabled, type }: BaseProps) {
if (type === 'error') {
return { color: theme.colors.error, opacity: stateOpacity.enabled };
}

if (disabled) {
return {
color: theme.colors.onSurfaceVariant,
opacity: stateOpacity.disabled,
};
return getStateLayer(theme, 'error', 'enabled');
}

return {
color: theme.colors.onSurfaceVariant,
opacity: stateOpacity.enabled,
};
return getStateLayer(
theme,
'onSurfaceVariant',
disabled ? 'disabled' : 'enabled'
);
}
2 changes: 1 addition & 1 deletion src/components/IconButton/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ColorValue } from 'react-native';
import { tokens } from '../../theme/tokens';
import type { InternalTheme } from '../../types';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

type IconButtonMode = 'outlined' | 'contained' | 'contained-tonal';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Menu/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { tokens } from '../../theme/tokens';
import type { InternalTheme } from '../../types';
import type { IconSource } from '../Icon';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

export const MIN_WIDTH = 112;
export const MAX_WIDTH = 280;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { addEventListener } from '../utils/addEventListener';
import { BackHandler } from '../utils/BackHandler/BackHandler';
import useAnimatedValue from '../utils/useAnimatedValue';

const { scrimAlpha } = tokens.md.ref;
const scrimAlpha = tokens.md.sys.scrim.alpha;

export type Props = {
/**
Expand Down
8 changes: 2 additions & 6 deletions src/components/RadioButton/RadioButtonItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { RadioButtonContext, RadioButtonContextType } from './RadioButtonGroup';
import RadioButtonIOS from './RadioButtonIOS';
import { handlePress, isChecked } from './utils';
import { useInternalTheme } from '../../core/theming';
import { tokens } from '../../theme/tokens';
import { getStateLayer } from '../../theme/utils/state';
import type { ThemeProp, TypescaleKey } from '../../types';
import TouchableRipple, {
Props as TouchableRippleProps,
Expand Down Expand Up @@ -179,14 +179,10 @@ const RadioButtonItem = ({
radioButton = <RadioButton {...radioButtonProps} />;
}

const textColor = theme.colors.onSurface;
const textAlign = isLeading ? 'right' : 'left';

const computedStyle = {
color: textColor,
opacity: disabled
? tokens.md.ref.stateOpacity.disabled
: tokens.md.ref.stateOpacity.enabled,
...getStateLayer(theme, 'onSurface', disabled ? 'disabled' : 'enabled'),
textAlign,
} as TextStyle;

Expand Down
2 changes: 1 addition & 1 deletion src/components/RadioButton/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ColorValue, GestureResponderEvent } from 'react-native';
import { tokens } from '../../theme/tokens';
import type { InternalTheme } from '../../types';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

export const handlePress = ({
onPress,
Expand Down
2 changes: 1 addition & 1 deletion src/components/SegmentedButtons/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ViewStyle } from 'react-native';
import { tokens } from '../../theme/tokens';
import type { InternalTheme } from '../../types';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

type BaseProps = {
theme: InternalTheme;
Expand Down
12 changes: 7 additions & 5 deletions src/components/TextInput/Adornment/utils.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import type { ColorValue } from 'react-native';

import { tokens } from '../../../theme/tokens';
import { getStateLayer } from '../../../theme/utils/state';
import type { InternalTheme } from '../../../types';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

type BaseProps = {
theme: InternalTheme;
disabled?: boolean;
};

export function getTextColor({ theme, disabled }: BaseProps) {
return {
color: theme.colors.onSurfaceVariant,
opacity: disabled ? stateOpacity.disabled : stateOpacity.enabled,
};
return getStateLayer(
theme,
'onSurfaceVariant',
disabled ? 'disabled' : 'enabled'
);
}

export function getIconColor({
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextInput/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { TextInputLabelProp } from './types';
import { tokens } from '../../theme/tokens';
import type { InternalTheme } from '../../types';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

type PaddingProps = {
height: number | null;
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { tokens } from '../../theme/tokens';
import Button from '../Button/Button';
import { getButtonColors } from '../Button/utils';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

const styles = StyleSheet.create({
flexing: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/Checkbox/utils.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getTheme } from '../../../core/theming';
import { tokens } from '../../../theme/tokens';
import { getSelectionControlColor } from '../../Checkbox/utils';
const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

describe('getSelectionControlColor - checkbox color', () => {
it('should return correct disabled color, for theme version 3', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/Chip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { tokens } from '../../theme/tokens';
import Chip from '../Chip/Chip';
import { getChipColors } from '../Chip/helpers';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

it('renders chip with onPress', () => {
const tree = render(<Chip onPress={() => {}}>Example Chip</Chip>).toJSON();
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/IconButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { tokens } from '../../theme/tokens';
import IconButton from '../IconButton/IconButton';
import { getIconButtonColor } from '../IconButton/utils';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

const styles = StyleSheet.create({
square: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/MenuItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { tokens } from '../../theme/tokens';
import Menu from '../Menu/Menu';
import { getMenuItemColor } from '../Menu/utils';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

describe('Menu Item', () => {
it('renders menu item', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { LightTheme } from '../../theme/schemes';
import { tokens } from '../../theme/tokens';
import Modal from '../Modal';

const { scrimAlpha } = tokens.md.ref;
const scrimAlpha = tokens.md.sys.scrim.alpha;

jest.mock('react-native-safe-area-context', () => ({
useSafeAreaInsets: () => ({ bottom: 44, left: 0, right: 0, top: 37 }),
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/RadioButton/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getTheme } from '../../../core/theming';
import { tokens } from '../../../theme/tokens';
import { getSelectionControlIOSColor } from '../../RadioButton/utils';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

describe('getSelectionControlIOSColor - checked color', () => {
it('should return correct disabled color, for theme version 3', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/SegmentedButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getSegmentedButtonColors,
} from '../SegmentedButtons/utils';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

it('renders segmented button', () => {
const tree = render(
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/TextInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '../TextInput/helpers';
import TextInput, { Props } from '../TextInput/TextInput';

const { stateOpacity } = tokens.md.ref;
const stateOpacity = tokens.md.sys.state.opacity;

const style = StyleSheet.create({
inputStyle: {
Expand Down
4 changes: 2 additions & 2 deletions src/theme/schemes/DarkTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { themeDefaults } from './base';
import { tokens } from '../tokens';
import { buildScheme } from '../tokens/sys/color/roles';
import { buildScheme } from '../tokens/sys/color';
import { defaultShapes } from '../tokens/sys/shape';
import type { Theme } from '../types';

export const DarkTheme: Theme = {
...themeDefaults,
dark: true,
colors: buildScheme(tokens.md.ref.palette, tokens.md.ref, { mode: 'dark' }),
colors: buildScheme(tokens.md.ref.palette, { mode: 'dark' }),
shapes: defaultShapes,
};
4 changes: 2 additions & 2 deletions src/theme/schemes/LightTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { themeDefaults } from './base';
import { tokens } from '../tokens';
import { buildScheme } from '../tokens/sys/color/roles';
import { buildScheme } from '../tokens/sys/color';
import { defaultShapes } from '../tokens/sys/shape';
import type { Theme } from '../types';

export const LightTheme: Theme = {
...themeDefaults,
dark: false,
colors: buildScheme(tokens.md.ref.palette, tokens.md.ref, { mode: 'light' }),
colors: buildScheme(tokens.md.ref.palette, { mode: 'light' }),
shapes: defaultShapes,
};
Loading