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

import Textarea from '~components/textarea';

import ScreenshotArea from '../utils/screenshot-area';

export default function TextareaPseudoSelectorsPage() {
const [value, setValue] = useState('Test value');
const [isInvalid, setIsInvalid] = useState(false);
const [isDisabled, setIsDisabled] = useState(false);
const [isReadOnly, setIsReadOnly] = useState(false);
const [isWarning, setIsWarning] = useState(false);
const [customStyling, setCustomStyling] = useState(false);

const customStyle = {
root: {
borderColor: {
default: '#3b82f6',
hover: '#2563eb',
focus: '#1d4ed8',
disabled: '#93c5fd',
readonly: '#60a5fa',
},
borderWidth: '2px',
borderRadius: '8px',
backgroundColor: {
default: '#dbeafe',
hover: '#bfdbfe',
focus: '#bfdbfe',
disabled: '#eff6ff',
readonly: '#f0f9ff',
},
color: {
default: '#1e40af',
hover: '#1e40af',
focus: '#1e3a8a',
disabled: '#93c5fd',
readonly: '#3b82f6',
},
fontSize: '16px',
fontWeight: '500',
paddingBlock: '10px',
paddingInline: '14px',
},
placeholder: {
color: '#60a5fa',
fontSize: '14px',
fontStyle: 'italic',
},
};

return (
<>
<h1>Textarea Style API - Pseudo Selectors</h1>
<ScreenshotArea>
<Textarea
ariaLabel="Test textarea"
value={value}
onChange={event => setValue(event.detail.value)}
invalid={isInvalid}
disabled={isDisabled}
readOnly={isReadOnly}
warning={isWarning}
placeholder="Enter text"
data-testid="test-textarea"
style={customStyling ? customStyle : undefined}
/>
</ScreenshotArea>

<div style={{ display: 'flex', gap: '10px', flexWrap: 'wrap', marginTop: '20px' }}>
<button id="toggle-styling" onClick={() => setCustomStyling(!customStyling)} type="button">
Copy link
Member

@georgylobko georgylobko Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[non-blocking] You can use the toggle button component instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Toggle Custom Styling ({customStyling ? 'ON' : 'OFF'})
</button>
<button id="toggle-invalid" onClick={() => setIsInvalid(!isInvalid)} type="button">
Toggle Invalid ({isInvalid ? 'ON' : 'OFF'})
</button>
<button id="toggle-disabled" onClick={() => setIsDisabled(!isDisabled)} type="button">
Toggle Disabled ({isDisabled ? 'ON' : 'OFF'})
</button>
<button id="toggle-readonly" onClick={() => setIsReadOnly(!isReadOnly)} type="button">
Toggle ReadOnly ({isReadOnly ? 'ON' : 'OFF'})
</button>
<button id="toggle-warning" onClick={() => setIsWarning(!isWarning)} type="button">
Toggle Warning ({isWarning ? 'ON' : 'OFF'})
</button>
<button
id="reset-all"
onClick={() => {
setCustomStyling(false);
setIsInvalid(false);
setIsDisabled(false);
setIsReadOnly(false);
setIsWarning(false);
}}
type="button"
>
Reset All
</button>
</div>
</>
);
}
181 changes: 181 additions & 0 deletions pages/textarea/style-permutations.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import Textarea, { TextareaProps } from '~components/textarea';

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

const permutations = createPermutations<TextareaProps>([
{
value: ['This is an example value'],
placeholder: [''],
disabled: [false, true],
readOnly: [false, true],
onChange: [() => {}],
style: [
{
root: {
borderColor: {
default: '#14b8a6',
hover: '#0f766e',
focus: '#0d9488',
disabled: '#99f6e4',
readonly: '#5eead4',
},
borderWidth: '2px',
borderRadius: '8px',
backgroundColor: {
default: '#99f6e4',
hover: '#5eead4',
focus: '#5eead4',
disabled: '#5eead4',
readonly: '#ccfbf1',
},
boxShadow: {
default: '0 1px 2px rgba(0, 0, 0, 0.05)',
hover: '0 2px 4px rgba(20, 184, 166, 0.15)',
focus: '0 0 0 4px rgba(20, 184, 166, 0.2), 0 2px 4px rgba(20, 184, 166, 0.15)',
disabled: 'none',
readonly: '0 1px 2px rgba(0, 0, 0, 0.05)',
},
color: {
default: '#0d5c54',
hover: '#0d5c54',
focus: '#0d5c54',
disabled: '#0d5c54',
readonly: '#0f766e',
},
fontSize: '16px',
fontWeight: '500',
paddingBlock: '12px',
paddingInline: '16px',
},
placeholder: {
color: '#14b8a6',
fontSize: '14px',
fontStyle: 'italic',
fontWeight: '400',
},
},
{
root: {
borderColor: {
default: '#ef4444',
hover: '#b91c1c',
focus: '#dc2626',
disabled: '#fca5a5',
readonly: '#fca5a5',
},
borderWidth: '2px',
borderRadius: '8px',
backgroundColor: {
default: '#fecaca',
hover: '#fca5a5',
focus: '#fca5a5',
disabled: '#fca5a5',
readonly: '#fee2e2',
},
boxShadow: {
default: '0 1px 2px rgba(0, 0, 0, 0.05)',
hover: '0 2px 4px rgba(239, 68, 68, 0.15)',
focus: '0 0 0 4px rgba(239, 68, 68, 0.2), 0 2px 4px rgba(239, 68, 68, 0.15)',
disabled: 'none',
readonly: '0 1px 2px rgba(0, 0, 0, 0.05)',
},
color: {
default: '#7f1d1d',
hover: '#7f1d1d',
focus: '#7f1d1d',
disabled: '#7f1d1d',
readonly: '#991b1b',
},
},
},
{
root: {
borderColor: {
default: '#f59e0b',
hover: '#b45309',
focus: '#d97706',
disabled: '#fcd34d',
readonly: '#fcd34d',
},
borderWidth: '2px',
borderRadius: '16px',
backgroundColor: {
default: '#fde68a',
hover: '#fcd34d',
focus: '#fcd34d',
disabled: '#fcd34d',
readonly: '#fef3c7',
},
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: '#78350f',
hover: '#78350f',
focus: '#78350f',
disabled: '#78350f',
readonly: '#92400e',
},
},
},
{
root: {
borderColor: {
default: '#10b981',
hover: '#047857',
focus: '#059669',
disabled: '#6ee7b7',
readonly: '#6ee7b7',
},
borderWidth: '3px',
borderRadius: '0px',
backgroundColor: {
default: '#d1fae5',
hover: '#a7f3d0',
focus: '#a7f3d0',
disabled: '#a7f3d0',
readonly: '#ecfdf5',
},
boxShadow: {
default: '0 1px 2px rgba(0, 0, 0, 0.05)',
hover: '0 2px 4px rgba(16, 185, 129, 0.1)',
focus: '0 0 0 4px rgba(16, 185, 129, 0.2), 0 2px 4px rgba(16, 185, 129, 0.15)',
disabled: 'none',
readonly: '0 1px 2px rgba(0, 0, 0, 0.05)',
},
color: {
default: '#064e3b',
hover: '#064e3b',
focus: '#064e3b',
disabled: '#064e3b',
readonly: '#065f46',
},
},
},
],
},
]);

export default function TextareaStylePermutations() {
return (
<>
<h1>Textarea Style permutations</h1>
<ScreenshotArea disableAnimations={true}>
<PermutationsView
permutations={permutations}
render={permutation => <Textarea ariaLabel="Textarea field" {...permutation} />}
/>
</ScreenshotArea>
</>
);
}
Loading
Loading