-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add loading prop to Text- and PropertyFilter to improve countT…
…ext announcement (#3122) Co-authored-by: Johannes Weber <[email protected]>
- Loading branch information
1 parent
85cb377
commit c3fcf07
Showing
13 changed files
with
645 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import React from 'react'; | ||
|
||
import { I18nProvider } from '~components/i18n'; | ||
import messages from '~components/i18n/messages/all.en'; | ||
import PropertyFilter, { PropertyFilterProps } from '~components/property-filter'; | ||
import SpaceBetween from '~components/space-between'; | ||
|
||
export default function () { | ||
const [query, setQuery] = React.useState<PropertyFilterProps['query']>({ | ||
tokens: [ | ||
{ | ||
operator: '=', | ||
propertyKey: 'instanceid', | ||
value: 'i-2dc5ce28a0328391', | ||
}, | ||
], | ||
operation: 'and', | ||
}); | ||
const [countText, setCountText] = React.useState(''); | ||
const [loading, setLoading] = React.useState(false); | ||
const propertyFilterRef = React.useRef<PropertyFilterProps.Ref>(null); | ||
|
||
return ( | ||
<I18nProvider messages={[messages]} locale="en"> | ||
<h1>Demo page for countText live announcement testing</h1> | ||
<SpaceBetween size="l"> | ||
<SpaceBetween direction="horizontal" size="s" key="settings"> | ||
<span>Count Text:</span> | ||
{['18 matches', '36 matches', ''].map((countText, index) => ( | ||
<label key={index}> | ||
<input type="radio" name="count-text" value={countText} onChange={() => setCountText(countText)} />{' '} | ||
{countText !== '' ? countText : '[Empty]'} | ||
</label> | ||
))} | ||
</SpaceBetween> | ||
<label htmlFor="loading-state-toggle" key="loadingStateToggle"> | ||
<input id="loading-state-toggle" type="checkbox" onChange={event => setLoading(event.target.checked)} />{' '} | ||
Loading | ||
</label> | ||
<PropertyFilter | ||
key="property-filter" | ||
query={query} | ||
onChange={({ detail }) => setQuery(detail)} | ||
countText={countText} | ||
ref={propertyFilterRef} | ||
expandToViewport={true} | ||
filteringAriaLabel="Find distributions" | ||
loading={loading} | ||
filteringOptions={[ | ||
{ | ||
propertyKey: 'instanceid', | ||
value: 'i-2dc5ce28a0328391', | ||
}, | ||
{ | ||
propertyKey: 'instanceid', | ||
value: 'i-d0312e022392efa0', | ||
}, | ||
{ | ||
propertyKey: 'instanceid', | ||
value: 'i-070eef935c1301e6', | ||
}, | ||
{ | ||
propertyKey: 'instanceid', | ||
value: 'i-3b44795b1fea36ac', | ||
}, | ||
{ propertyKey: 'state', value: 'Stopped' }, | ||
{ propertyKey: 'state', value: 'Stopping' }, | ||
{ propertyKey: 'state', value: 'Pending' }, | ||
{ propertyKey: 'state', value: 'Running' }, | ||
{ | ||
propertyKey: 'instancetype', | ||
value: 't3.small', | ||
}, | ||
{ | ||
propertyKey: 'instancetype', | ||
value: 't2.small', | ||
}, | ||
{ propertyKey: 'instancetype', value: 't3.nano' }, | ||
{ | ||
propertyKey: 'instancetype', | ||
value: 't2.medium', | ||
}, | ||
{ | ||
propertyKey: 'instancetype', | ||
value: 't3.medium', | ||
}, | ||
{ | ||
propertyKey: 'instancetype', | ||
value: 't2.large', | ||
}, | ||
{ propertyKey: 'instancetype', value: 't2.nano' }, | ||
{ | ||
propertyKey: 'instancetype', | ||
value: 't2.micro', | ||
}, | ||
{ | ||
propertyKey: 'instancetype', | ||
value: 't3.large', | ||
}, | ||
{ | ||
propertyKey: 'instancetype', | ||
value: 't3.micro', | ||
}, | ||
{ propertyKey: 'averagelatency', value: '17' }, | ||
{ propertyKey: 'averagelatency', value: '53' }, | ||
{ propertyKey: 'averagelatency', value: '73' }, | ||
{ propertyKey: 'averagelatency', value: '74' }, | ||
{ propertyKey: 'averagelatency', value: '107' }, | ||
{ propertyKey: 'averagelatency', value: '236' }, | ||
{ propertyKey: 'averagelatency', value: '242' }, | ||
{ propertyKey: 'averagelatency', value: '375' }, | ||
{ propertyKey: 'averagelatency', value: '402' }, | ||
{ propertyKey: 'averagelatency', value: '636' }, | ||
{ propertyKey: 'averagelatency', value: '639' }, | ||
{ propertyKey: 'averagelatency', value: '743' }, | ||
{ propertyKey: 'averagelatency', value: '835' }, | ||
{ propertyKey: 'averagelatency', value: '981' }, | ||
{ propertyKey: 'averagelatency', value: '995' }, | ||
]} | ||
filteringPlaceholder="Find distributions" | ||
filteringProperties={[ | ||
{ | ||
key: 'instanceid', | ||
operators: ['=', '!=', ':', '!:', '^', '!^'], | ||
propertyLabel: 'Instance ID', | ||
groupValuesLabel: 'Instance ID values', | ||
}, | ||
{ | ||
key: 'state', | ||
operators: ['=', '!=', ':', '!:', '^', '!^'], | ||
propertyLabel: 'State', | ||
groupValuesLabel: 'State values', | ||
}, | ||
{ | ||
key: 'instancetype', | ||
operators: ['=', '!=', ':', '!:', '^', '!^'], | ||
propertyLabel: 'Instance type', | ||
groupValuesLabel: 'Instance type values', | ||
}, | ||
{ | ||
key: 'averagelatency', | ||
operators: ['=', '!=', '>', '<', '<=', '>='], | ||
propertyLabel: 'Average latency', | ||
groupValuesLabel: 'Average latency values', | ||
}, | ||
]} | ||
/> | ||
</SpaceBetween> | ||
</I18nProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import React from 'react'; | ||
|
||
import { I18nProvider } from '~components/i18n'; | ||
import messages from '~components/i18n/messages/all.en'; | ||
import SpaceBetween from '~components/space-between'; | ||
import TextFilter, { TextFilterProps } from '~components/text-filter'; | ||
|
||
export default function () { | ||
const [filteringText, setFilteringText] = React.useState('Hello World'); | ||
const [countText, setCountText] = React.useState(''); | ||
const [loading, setLoading] = React.useState(false); | ||
const textFilterRef = React.useRef<TextFilterProps.Ref>(null); | ||
|
||
return ( | ||
<I18nProvider messages={[messages]} locale="en"> | ||
<h1>Demo page for countText live announcement testing</h1> | ||
<SpaceBetween size="l"> | ||
<SpaceBetween direction="horizontal" size="s" key="settings"> | ||
<span>Count Text:</span> | ||
{['18 matches', '36 matches', ''].map((countText, index) => ( | ||
<label key={index}> | ||
<input type="radio" name="count-text" value={countText} onChange={() => setCountText(countText)} />{' '} | ||
{countText !== '' ? countText : '[Empty]'} | ||
</label> | ||
))} | ||
</SpaceBetween> | ||
<label htmlFor="loading-state-toggle" key="loadingStateToggle"> | ||
<input id="loading-state-toggle" type="checkbox" onChange={event => setLoading(event.target.checked)} />{' '} | ||
Loading | ||
</label> | ||
<TextFilter | ||
filteringText={filteringText} | ||
filteringPlaceholder="Find instances" | ||
filteringAriaLabel="Filter instances" | ||
loading={loading} | ||
countText={countText} | ||
onChange={({ detail }) => setFilteringText(detail.filteringText)} | ||
ref={textFilterRef} | ||
/> | ||
</SpaceBetween> | ||
</I18nProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.