From 958c864f54b7b859c5daf857721d2ff8a76c313f Mon Sep 17 00:00:00 2001 From: teonemes Date: Thu, 25 Sep 2025 12:59:26 +0200 Subject: [PATCH 1/6] chore: Update custom dev pages to use light-dark method --- pages/alert/style-custom-types.page.tsx | 146 ++++----- pages/badge/style-custom-types.page.tsx | 101 +++--- .../button-group/style-custom-types.page.tsx | 292 +++++------------- pages/button/style-permutations.page.tsx | 240 ++++++++------ pages/checkbox/style-custom.page.tsx | 31 +- pages/container/style-custom.page.tsx | 7 +- pages/link/style-custom-types.page.tsx | 92 ++---- pages/radio-group/style-custom.page.tsx | 35 +-- pages/toggle/style-custom.page.tsx | 28 +- 9 files changed, 383 insertions(+), 589 deletions(-) diff --git a/pages/alert/style-custom-types.page.tsx b/pages/alert/style-custom-types.page.tsx index 59bc4882bc..913b7d05bc 100644 --- a/pages/alert/style-custom-types.page.tsx +++ b/pages/alert/style-custom-types.page.tsx @@ -1,8 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import React, { useRef } from 'react'; - -import { useCurrentMode } from '@cloudscape-design/component-toolkit/internal'; +import React from 'react'; import { Alert as CloudscapeAlert, Button, SpaceBetween } from '~components'; @@ -68,11 +66,6 @@ interface CustomAlertProps { } function CustomAlert({ children, type, dismissible, action }: CustomAlertProps) { - const mode = useCurrentMode(useRef(document.body)); - const background = backgrounds[mode][type]; - const borderColor = borderColors[mode][type]; - const borderWidth = borderWidths[type]; - const color = colors[mode]; return ( ); } - -const backgrounds = { - light: { - blue: 'rgba(166, 222, 255, 0.91)', - green: 'rgba(152, 234, 182, 0.87)', - orange: 'rgba(223, 146, 91, 1)', - red: 'rgba(234, 91, 86, 0.52)', - teal: 'rgba(138, 237, 225, 0.76)', - nav: 'rgba(205, 202, 202, 0.85)', - }, - dark: { - blue: 'rgba(64, 123, 178, 0.8)', - green: 'rgba(34, 197, 94, 0.3)', - orange: 'rgba(204, 90, 9, 0.81)', - red: 'rgba(210, 60, 60, 0.63)', - teal: 'rgba(9, 188, 155, 0.71)', - nav: 'rgba(124, 122, 122, 1)', - }, -}; - -const borderColors = { - light: { - green: 'rgba(24, 146, 69, 0.4)', - red: 'rgba(239, 68, 68, 0.4)', - }, - dark: { - green: 'rgba(34, 197, 94, 0.6)', - red: 'rgba(239, 68, 68, 0.6)', - }, -}; - -const boxShadows = { - light: { - blue: '0 2px 12px rgba(59, 130, 246, 0.15)', - green: '0 2px 12px rgba(34, 197, 94, 0.15)', - orange: '0 2px 12px rgba(249, 115, 22, 0.15)', - red: '0 2px 12px rgba(239, 68, 68, 0.15)', - teal: '0 2px 12px rgba(20, 184, 166, 0.15)', - nav: '0 4px 20px rgba(0, 0, 0, 0.1)', - }, - dark: { - blue: '0 2px 12px rgba(59, 130, 246, 0.25)', - green: '0 2px 12px rgba(34, 197, 94, 0.25)', - orange: '0 2px 12px rgba(249, 115, 22, 0.25)', - red: '0 2px 12px rgba(239, 68, 68, 0.25)', - teal: '0 2px 12px rgba(20, 184, 166, 0.25)', - nav: '0 4px 20px rgba(255, 255, 255, 0.1)', - }, -}; - -const focusRingColors = { - light: { - blue: palette.blue80, - green: palette.green60, - orange: palette.orange60, - red: palette.red80, - teal: palette.teal80, - nav: palette.neutral80, - }, - dark: { - blue: palette.blue40, - green: palette.green30, - orange: palette.orange40, - red: palette.red30, - teal: palette.teal40, - nav: palette.neutral40, - }, -}; - -const itemColors = { - light: { - blue: { - active: palette.blue100, - default: palette.blue90, - hover: palette.blue100, - }, - green: { - active: palette.green100, - default: palette.green90, - hover: palette.green100, - }, - orange: { - active: palette.orange100, - default: palette.orange90, - hover: palette.orange100, - }, - red: { - active: palette.red100, - default: palette.red80, - hover: palette.red100, - }, - teal: { - active: palette.teal100, - default: palette.teal80, - hover: palette.teal100, - }, - nav: { - active: palette.neutral100, - default: palette.neutral80, - hover: palette.neutral100, - }, - disabled: palette.neutral60, - }, - dark: { - blue: { - active: palette.blue10, - default: palette.blue20, - hover: palette.blue10, - }, - green: { - active: palette.green10, - default: palette.green20, - hover: palette.green10, - }, - orange: { - active: palette.orange10, - default: palette.orange20, - hover: palette.orange10, - }, - red: { - active: palette.red10, - default: palette.red20, - hover: palette.red10, - }, - teal: { - active: palette.teal10, - default: palette.teal20, - hover: palette.teal10, - }, - nav: { - active: palette.neutral10, - default: palette.neutral20, - hover: palette.neutral10, - }, - disabled: palette.neutral40, - }, -}; +function getBoxShadow(colorTheme: string) { + const boxShadows = { + blue: `0 2px 12px light-dark(rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.25))`, + green: `0 2px 12px light-dark(rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.25))`, + orange: `0 2px 12px light-dark(rgba(249, 115, 22, 0.15), rgba(249, 115, 22, 0.25))`, + red: `0 2px 12px light-dark(rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.25))`, + teal: `0 2px 12px light-dark(rgba(20, 184, 166, 0.15),rgba(20, 184, 166, 0.25))`, + nav: `0 4px 20px light-dark(rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0.1))`, + }; + return boxShadows[colorTheme as keyof typeof boxShadows]; +} diff --git a/pages/button/style-permutations.page.tsx b/pages/button/style-permutations.page.tsx index 93a06b0946..05c0c5bf6b 100644 --- a/pages/button/style-permutations.page.tsx +++ b/pages/button/style-permutations.page.tsx @@ -2,99 +2,163 @@ // SPDX-License-Identifier: Apache-2.0 import React from 'react'; -import Button, { ButtonProps } from '~components/button'; +import { Button as CloudscapeButton, SpaceBetween } from '~components'; -import createPermutations from '../utils/permutations'; -import PermutationsView from '../utils/permutations-view'; +import { palette } from '../app/themes/style-api'; import ScreenshotArea from '../utils/screenshot-area'; -const permutations = createPermutations([ - { - ariaLabel: ['Border Styles'], - children: ['Border Styles'], - disabled: [false, true], - iconName: ['add-plus'], - iconAlt: ['add-plus'], - style: [ - { - root: { - borderColor: { - active: 'purple', - default: 'magenta', - hover: 'orange', - disabled: 'brown', - }, - borderRadius: '2px', - borderWidth: '4px', - }, - }, - ], - variant: ['primary', 'normal', 'link', 'icon', 'inline-icon', 'inline-link'], - }, - { - ariaLabel: ['Background and Color Styles'], - children: ['Background and Color Styles'], - disabled: [false, true], - iconName: ['arrow-left'], - iconAlt: ['arrow-left'], - loading: [false, true], - style: [ - { +export default function CustomButtonTypes() { + return ( + +

Custom Button Types

+ + + + Default + + + Success + + + Error + + + Info + + + Warning + + + isDisabled + + + isLoading + + +
+ ); +} + +interface CustomButtonProps { + children?: React.ReactNode; + colorTheme: 'default' | 'error' | 'info' | 'warning' | 'success'; + id?: string; + isDisabled?: boolean; + isLoading?: boolean; + onClick?: any; + variation: 'primary'; +} + +function CustomButton({ children, colorTheme, id, isDisabled, isLoading, onClick, variation }: CustomButtonProps) { + return ( + -

Button Style permutations

- -