import { Platform } from 'react-native'; import type { GlobalTheme } from '../global'; const getButtonTheme = (theme: GlobalTheme) => { const fonts = { default: theme.fonts.neutral.semiBold, utility: theme.fonts.neutral.regular, }; const fontSize = { default: theme.fontSizes.xlarge, utility: theme.fontSizes.large, textVariant: theme.fontSizes.large, }; const borderWidth = { default: theme.space.xxsmall, }; const space = { default: { buttonPadding: theme.space.medium, iconPadding: theme.space.smallMedium, textButtonPadding: theme.space.smallMedium, }, compact: { buttonPaddingVertical: theme.space.small, buttonPaddingHorizontal: theme.space.medium, iconPadding: theme.space.small, }, medium: { buttonPaddingVertical: theme.space.small, buttonPaddingHorizontal: theme.space.medium, iconPadding: theme.space.smallMedium, buttonPadding: theme.space.medium, textButtonPadding: theme.space.xlarge, }, utilityPadding: theme.space.small, }; const sizes = { iconSize: { default: theme.fontSizes.xxlarge, compact: theme.fontSizes.small, }, }; const radii = { default: theme.radii['5xlarge'], rounded: theme.radii.rounded, utilityRadii: theme.radii.medium, text: theme.radii.base, }; const colors = { invertedText: theme.colors.onDarkGlobalSurface, utilityBackground: theme.colors.defaultGlobalSurface, background: { filledPrimary: theme.colors.primary, filledSecondary: theme.colors.neutralGlobalSurface, filledDanger: theme.colors.error, filledWhite: theme.colors.defaultGlobalSurface, filledInverted: theme.colors.defaultGlobalSurface, }, text: { filledPrimary: theme.colors.onDarkGlobalSurface, filledSecondary: theme.colors.onDefaultGlobalSurface, filledDanger: theme.colors.white, filledWhite: theme.colors.primary, filledInverted: theme.colors.primary, outlinedPrimary: theme.colors.primary, outlinedSecondary: theme.colors.onDefaultGlobalSurface, outlinedDanger: theme.colors.onErrorSurface, outlinedWhite: theme.colors.onDarkGlobalSurface, outlinedInverted: theme.colors.onDarkGlobalSurface, textPrimary: theme.colors.primary, textSecondary: theme.colors.onDefaultGlobalSurface, textDanger: theme.colors.onErrorSurface, textWhite: theme.colors.onDarkGlobalSurface, textInverted: theme.colors.onDarkGlobalSurface, }, border: { outlinedPrimary: theme.colors.primary, outlinedSecondary: theme.colors.secondaryOutline, outlinedDanger: theme.colors.onErrorSurface, outlinedWhite: theme.colors.defaultGlobalSurface, outlinedInverted: theme.colors.defaultGlobalSurface, }, pressedBackground: { filledPrimary: theme.colors.pressedSurface, filledSecondary: theme.colors.archivedSurface, filledDanger: theme.colors.mutedError, filledWhite: theme.colors.highlightedSurface, filledInverted: theme.colors.highlightedSurface, outlinedPrimary: theme.colors.highlightedSurface, outlinedSecondary: theme.colors.highlightedSurface, outlinedDanger: theme.colors.errorSurface, outlinedWhite: theme.colors.pressedSurface, outlinedInverted: theme.colors.pressedSurface, textPrimary: theme.colors.highlightedSurface, textSecondary: theme.colors.highlightedSurface, textDanger: theme.colors.errorSurface, textWhite: theme.colors.pressedSurface, textInverted: theme.colors.pressedSurface, }, pressedText: { inlineTextPrimary: theme.colors.secondary, inlineTextSecondary: theme.colors.onArchivedSurface, inlineTextDanger: theme.colors.error, inlineTextWhite: theme.colors.secondary, inlineTextInverted: theme.colors.secondary, }, }; const lineHeights = { titleOfTextVariant: { default: theme.lineHeights.medium, compact: theme.lineHeights.small, }, buttonText: Platform.select({ android: theme.lineHeights.medium + theme.space.xxsmall, }), utilityButtonText: Platform.select({ android: theme.lineHeights.small + theme.space.xxsmall, }), compactButtonText: Platform.select({ android: theme.lineHeights.small + theme.space.xxsmall, }), }; return { lineHeights, borderWidth, fonts, fontSize, sizes, radii, colors, space, }; }; type GetButtonThemeReturnType = ReturnType; export interface ButtonThemeType extends GetButtonThemeReturnType { /** * @deprecated will be removed in v9 * */ fonts: GetButtonThemeReturnType['fonts']; /** * @deprecated will be removed in v9 * */ fontSize: GetButtonThemeReturnType['fontSize']; } export default getButtonTheme;