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
106 changes: 106 additions & 0 deletions pages/autosuggest/style-permutations.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import Autosuggest, { AutosuggestProps } from '~components/autosuggest';

import createPermutations from '../utils/permutations';
import PermutationsView from '../utils/permutations-view';
import ScreenshotArea from '../utils/screenshot-area';

const style1 = {
root: {
borderColor: {
default: 'light-dark(#f59e0b, #fbbf24)',
hover: 'light-dark(#b45309, #fcd34d)',
focus: 'light-dark(#d97706, #fde047)',
disabled: 'light-dark(#fcd34d, #fef08a)',
readonly: 'light-dark(#fcd34d, #fef08a)',
},
borderWidth: '2px',
borderRadius: '16px',
backgroundColor: {
default: 'light-dark(#fef3c7, #000000)',
hover: 'light-dark(#fefce8, #0a0a0a)',
focus: 'light-dark(#fef9c3, #0f0f0f)',
disabled: 'light-dark(#fcd34d, #1a1a1a)',
readonly: 'light-dark(#fef3c7, #0a0a0a)',
},
boxShadow: {
default: '0 2px 8px rgba(245, 158, 11, 0.15)',
hover: '0 6px 16px rgba(245, 158, 11, 0.25)',
focus: '0 0 0 4px rgba(245, 158, 11, 0.25), 0 6px 16px rgba(245, 158, 11, 0.3)',
disabled: 'none',
readonly: '0 2px 8px rgba(245, 158, 11, 0.15)',
},
color: {
default: 'light-dark(#78350f, #fef3c7)',
hover: 'light-dark(#78350f, #fef3c7)',
focus: 'light-dark(#78350f, #fef3c7)',
disabled: 'light-dark(#78350f, #fef3c7)',
readonly: 'light-dark(#92400e, #fde68a)',
},
},
placeholder: {
color: 'light-dark(black, white)',
},
};

const enteredTextLabel = (value: string) => `Use: ${value}`;

const permutations = createPermutations<AutosuggestProps>([
{
value: ['This is a test value'],
disabled: [false, true],
invalid: [false, true],
warning: [false, true],
style: [style1],
options: [
[
{ value: 'option1', label: 'Option 1' },
{ value: 'option2', label: 'Option 2' },
],
],
enteredTextLabel: [enteredTextLabel],
},
{
value: [''],
placeholder: ['Placeholder'],
disabled: [false, true],
invalid: [false, true],
warning: [false, true],
style: [style1],
options: [
[
{ value: 'option1', label: 'Option 1' },
{ value: 'option2', label: 'Option 2' },
],
],
enteredTextLabel: [enteredTextLabel],
},
]);

export default function AutosuggestStylePermutations() {
return (
<>
<h1>Autosuggest Style permutations</h1>
<ScreenshotArea disableAnimations={true}>
<PermutationsView
permutations={permutations}
render={permutation => (
<div style={{ marginBottom: '100px' }}>
<Autosuggest
ariaLabel="Input field"
clearAriaLabel="Clear"
onChange={() => {
/*empty handler to suppress react controlled property warning*/
}}
{...permutation}
/>
</div>
)}
/>
</ScreenshotArea>
</>
);
}
230 changes: 230 additions & 0 deletions src/__tests__/snapshot-tests/__snapshots__/documenter.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3555,6 +3555,236 @@ This is required to provide a good screen reader experience. For more informatio
"optional": true,
"type": "string",
},
{
"inlineType": {
"name": "AutosuggestProps.Style",
"properties": [
{
"inlineType": {
"name": "object",
"properties": [
{
"name": "color",
"optional": true,
"type": "string",
},
{
"name": "fontSize",
"optional": true,
"type": "string",
},
{
"name": "fontStyle",
"optional": true,
"type": "string",
},
{
"name": "fontWeight",
"optional": true,
"type": "string",
},
],
"type": "object",
},
"name": "placeholder",
"optional": true,
"type": "{ color?: string | undefined; fontSize?: string | undefined; fontStyle?: string | undefined; fontWeight?: string | undefined; }",
},
{
"inlineType": {
"name": "object",
"properties": [
{
"inlineType": {
"name": "object",
"properties": [
{
"name": "default",
"optional": true,
"type": "string",
},
{
"name": "disabled",
"optional": true,
"type": "string",
},
{
"name": "focus",
"optional": true,
"type": "string",
},
{
"name": "hover",
"optional": true,
"type": "string",
},
{
"name": "readonly",
"optional": true,
"type": "string",
},
],
"type": "object",
},
"name": "backgroundColor",
"optional": true,
"type": "{ default?: string | undefined; disabled?: string | undefined; focus?: 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": "focus",
"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; focus?: string | undefined; hover?: string | undefined; readonly?: string | undefined; }",
},
{
"name": "borderRadius",
"optional": true,
"type": "string",
},
{
"name": "borderWidth",
"optional": true,
"type": "string",
},
{
"inlineType": {
"name": "object",
"properties": [
{
"name": "default",
"optional": true,
"type": "string",
},
{
"name": "disabled",
"optional": true,
"type": "string",
},
{
"name": "focus",
"optional": true,
"type": "string",
},
{
"name": "hover",
"optional": true,
"type": "string",
},
{
"name": "readonly",
"optional": true,
"type": "string",
},
],
"type": "object",
},
"name": "boxShadow",
"optional": true,
"type": "{ default?: string | undefined; disabled?: string | undefined; focus?: 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": "focus",
"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; focus?: string | undefined; hover?: string | undefined; readonly?: string | undefined; }",
},
{
"name": "fontSize",
"optional": true,
"type": "string",
},
{
"name": "fontWeight",
"optional": true,
"type": "string",
},
{
"name": "paddingBlock",
"optional": true,
"type": "string",
},
{
"name": "paddingInline",
"optional": true,
"type": "string",
},
],
"type": "object",
},
"name": "root",
"optional": true,
"type": "{ backgroundColor?: { default?: string | undefined; disabled?: string | undefined; focus?: string | undefined; hover?: string | undefined; readonly?: string | undefined; } | undefined; ... 8 more ...; paddingInline?: string | undefined; }",
},
],
"type": "object",
},
"name": "style",
"optional": true,
"systemTags": [
"core",
],
"type": "AutosuggestProps.Style",
},
{
"description": "Specifies the text entered into the form element.",
"name": "value",
Expand Down
Loading
Loading