Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
13 changes: 13 additions & 0 deletions build-tools/utils/custom-css-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,18 @@ const customCssPropertiesList = [
'styleSliderHandleBackgroundHover',
'styleSliderHandleBackgroundActive',
'styleSliderHandleBorderRadius',
// Token style properties
'tokenStyleBackgroundDefault',
'tokenStyleBackgroundDisabled',
'tokenStyleBackgroundHover',
'tokenStyleBackgroundReadOnly',
'tokenStyleBorderColorDefault',
'tokenStyleBorderColorDisabled',
'tokenStyleBorderColorHover',
'tokenStyleBorderColorReadOnly',
'tokenStyleDismissColorDefault',
'tokenStyleDismissColorDisabled',
'tokenStyleDismissColorHover',
'tokenStyleDismissColorReadOnly',
];
module.exports = customCssPropertiesList;
87 changes: 87 additions & 0 deletions pages/token/style-permutations.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import Icon from '~components/icon';
import Token, { TokenProps } from '~components/token';

import { SimplePage } from '../app/templates';
import createPermutations from '../utils/permutations';
import PermutationsView from '../utils/permutations-view';

const roundedPillStyle: TokenProps['style'] = {
root: {
background: {
default: 'light-dark(#eef2ff, #2e1065)',
hover: 'light-dark(#dbeafe, #3b0764)',
disabled: 'light-dark(#f1f5f9, #1e1b2e)',
readOnly: 'light-dark(#f8fafc, #1e1b3a)',
},
borderColor: {
default: 'light-dark(#c7d2fe, #6d28d9)',
hover: 'light-dark(#93c5fd, #7c3aed)',
disabled: 'light-dark(#e2e8f0, #334155)',
readOnly: 'light-dark(#cbd5e1, #4c1d95)',
},
borderRadius: '24px',
paddingBlock: '4px',
paddingInline: '12px',
},
dismissButton: {
color: {
default: 'light-dark(#6366f1, #a78bfa)',
hover: 'light-dark(#4338ca, #c4b5fd)',
disabled: 'light-dark(#cbd5e1, #475569)',
readOnly: 'light-dark(#94a3b8, #6d28d9)',
},
focusRing: {
borderColor: 'light-dark(#6366f1, #a78bfa)',
borderRadius: '12px',
borderWidth: '2px',
},
},
};

const greenOutlineStyle: TokenProps['style'] = {
root: {
background: {
default: 'light-dark(#ecfdf5, #022c22)',
hover: 'light-dark(#d1fae5, #064e3b)',
disabled: 'light-dark(#f8fafc, #1e1b2e)',
readOnly: 'light-dark(#f0fdf4, #0a3d2e)',
},
borderColor: {
default: 'light-dark(#6ee7b7, #059669)',
hover: 'light-dark(#34d399, #10b981)',
disabled: 'light-dark(#e2e8f0, #334155)',
readOnly: 'light-dark(#a7f3d0, #047857)',
},
borderRadius: '6px',
borderWidth: '2px',
paddingBlock: '4px',
paddingInline: '10px',
},
};

const permutations = createPermutations<TokenProps>([
{
label: ['Styled token'],
icon: [undefined, <Icon key="icon" name="settings" />],
onDismiss: [() => {}],
disabled: [false, true],
readOnly: [false, true],
variant: ['normal', 'inline'],
style: [roundedPillStyle, greenOutlineStyle],
},
]);

export default function TokenStylePermutations() {
return (
<SimplePage title="Token Style permutations" screenshotArea={{ disableAnimations: true }}>
<PermutationsView
permutations={permutations}
render={(permutation, index) => <Token {...permutation} dismissLabel={`Dismiss ${index}`} />}
/>
</SimplePage>
);
}
177 changes: 177 additions & 0 deletions src/__tests__/snapshot-tests/__snapshots__/documenter.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29749,6 +29749,183 @@ use the \`id\` attribute, consider setting it on a parent element instead.",
"optional": true,
"type": "boolean",
},
{
"description": "An object containing CSS properties to customize the token's visual appearance.
Refer to the [style](/components/token/?tabId=style) tab for more details.",
"inlineType": {
"name": "TokenProps.Style",
"properties": [
{
"inlineType": {
"name": "object",
"properties": [
{
"inlineType": {
"name": "object",
"properties": [
{
"name": "default",
"optional": true,
"type": "string",
},
{
"name": "disabled",
"optional": true,
"type": "string",
},
{
"name": "hover",
"optional": true,
"type": "string",
},
{
"name": "readOnly",
"optional": true,
"type": "string",
},
],
"type": "object",
},
"name": "color",
"optional": true,
"type": "{ default?: string | undefined; disabled?: string | undefined; hover?: string | undefined; readOnly?: string | undefined; }",
},
{
"inlineType": {
"name": "object",
"properties": [
{
"name": "borderColor",
"optional": true,
"type": "string",
},
{
"name": "borderRadius",
"optional": true,
"type": "string",
},
{
"name": "borderWidth",
"optional": true,
"type": "string",
},
],
"type": "object",
},
"name": "focusRing",
"optional": true,
"type": "{ borderColor?: string | undefined; borderRadius?: string | undefined; borderWidth?: string | undefined; }",
},
],
"type": "object",
},
"name": "dismissButton",
"optional": true,
"type": "{ color?: { default?: string | undefined; disabled?: string | undefined; hover?: string | undefined; readOnly?: string | undefined; } | undefined; focusRing?: { borderColor?: string | undefined; borderRadius?: string | undefined; borderWidth?: string | undefined; } | undefined; }",
},
{
"inlineType": {
"name": "object",
"properties": [
{
"inlineType": {
"name": "object",
"properties": [
{
"name": "default",
"optional": true,
"type": "string",
},
{
"name": "disabled",
"optional": true,
"type": "string",
},
{
"name": "hover",
"optional": true,
"type": "string",
},
{
"name": "readOnly",
"optional": true,
"type": "string",
},
],
"type": "object",
},
"name": "background",
"optional": true,
"type": "{ default?: string | undefined; disabled?: string | undefined; hover?: string | undefined; readOnly?: string | undefined; }",
},
{
"inlineType": {
"name": "object",
"properties": [
{
"name": "default",
"optional": true,
"type": "string",
},
{
"name": "disabled",
"optional": true,
"type": "string",
},
{
"name": "hover",
"optional": true,
"type": "string",
},
{
"name": "readOnly",
"optional": true,
"type": "string",
},
],
"type": "object",
},
"name": "borderColor",
"optional": true,
"type": "{ default?: string | undefined; disabled?: string | undefined; hover?: string | undefined; readOnly?: string | undefined; }",
},
{
"name": "borderRadius",
"optional": true,
"type": "string",
},
{
"name": "borderWidth",
"optional": true,
"type": "string",
},
{
"name": "paddingBlock",
"optional": true,
"type": "string",
},
{
"name": "paddingInline",
"optional": true,
"type": "string",
},
],
"type": "object",
},
"name": "root",
"optional": true,
"type": "{ background?: { default?: string | undefined; disabled?: string | undefined; hover?: string | undefined; readOnly?: string | undefined; } | undefined; borderColor?: { default?: string | undefined; disabled?: string | undefined; hover?: string | undefined; readOnly?: string | undefined; } | undefined; borderRadius?:...",
},
],
"type": "object",
},
"name": "style",
"optional": true,
"systemTags": [
"core",
],
"type": "TokenProps.Style",
},
{
"description": "A list of tags giving further guidance about the token.",
"name": "tags",
Expand Down
Loading
Loading