-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #882 from WestpacGEL/fix/style-fixes
Fix/style fixes
- Loading branch information
Showing
8 changed files
with
166 additions
and
46 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,5 @@ | ||
--- | ||
'@westpac/ui': minor | ||
--- | ||
|
||
updated progress-indicators to use IconProps |
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
10 changes: 6 additions & 4 deletions
10
packages/ui/src/components/progress-indicator/progress-indicator.component.tsx
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 |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import React from 'react'; | ||
|
||
import { Icon } from '../icon/icon.component.js'; | ||
|
||
import { styles } from './progress-indicator.styles.js'; | ||
import { type ProgressIndicatorProps } from './progress-indicator.types.js'; | ||
import { ProgressIndicatorProps } from './progress-indicator.types.js'; | ||
|
||
export function ProgressIndicator({ | ||
className, | ||
children, | ||
inverted = false, | ||
color = 'hero', | ||
size = 'medium', | ||
'aria-label': ariaLabel = 'Loading', | ||
...props | ||
}: ProgressIndicatorProps) { | ||
return ( | ||
<div className={styles({ className, size, inverted })} aria-label={ariaLabel} {...props}> | ||
<Icon className={styles({ className })} size={size} color={color} aria-label={ariaLabel} {...props}> | ||
{children} | ||
</div> | ||
</Icon> | ||
); | ||
} |
97 changes: 97 additions & 0 deletions
97
packages/ui/src/components/progress-indicator/progress-indicator.scenarios.stories.tsx
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,97 @@ | ||
import { type Meta, StoryFn, type StoryObj } from '@storybook/react'; | ||
import { useCallback, useState } from 'react'; | ||
|
||
import { Button } from '../button/button.component.js'; | ||
import { ClearIcon, DropDownIcon, SearchIcon } from '../icon/index.js'; | ||
import { Input } from '../input/input.component.js'; | ||
import { InputGroup } from '../input-group/input-group.component.js'; | ||
|
||
import { ProgressIndicator } from './progress-indicator.component.js'; | ||
|
||
const meta: Meta<typeof ProgressIndicator> = { | ||
title: 'Components/ProgressIndicator/Scenarios', | ||
component: ProgressIndicator, | ||
tags: ['autodocs'], | ||
decorators: [(Story: StoryFn) => <Story />], | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
/** | ||
* >Default usage example | ||
*/ | ||
export const Default: Story = { | ||
args: { size: 'xlarge' }, | ||
}; | ||
|
||
/** | ||
* >Usage in buttons | ||
*/ | ||
|
||
export const ButtonsUsage = () => { | ||
return ( | ||
<div> | ||
{(['large', 'medium', 'small'] as const).map(size => ( | ||
<> | ||
<h3 className="font-bold">{size.charAt(0).toUpperCase() + size.slice(1)}</h3> | ||
<div className="flex gap-2 py-2"> | ||
{(['primary', 'hero', 'faint'] as const).map(look => ( | ||
<Button | ||
size={size} | ||
look={look} | ||
key={`${size}-${look}`} | ||
iconAfter={ProgressIndicator} | ||
iconSize={size === 'small' ? 'xsmall' : 'small'} | ||
iconColor={look === 'faint' ? 'hero' : 'white'} | ||
> | ||
Loading...{' '} | ||
</Button> | ||
))} | ||
</div> | ||
</> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
/** | ||
* > Usage in input | ||
*/ | ||
|
||
export const InputUsage = () => { | ||
const [inputValue, setInputValue] = useState<string>(''); | ||
const clearInput = useCallback(() => setInputValue(''), []); | ||
|
||
return ( | ||
<> | ||
<InputGroup | ||
label="Input with left progress indicator" | ||
before={{ | ||
icon: ProgressIndicator, | ||
}} | ||
after={{ | ||
inset: true, | ||
element: <Button onClick={clearInput} look="link" iconAfter={ClearIcon} iconColor="muted" />, | ||
}} | ||
> | ||
<Input onChange={({ target: { value } }) => setInputValue(value)} value={inputValue} /> | ||
</InputGroup> | ||
<InputGroup | ||
label="Input with right progress indicator" | ||
before={{ | ||
inset: true, | ||
element: <Button onClick={clearInput} look="link" iconAfter={DropDownIcon} iconColor="muted" />, | ||
}} | ||
after={{ | ||
icon: ProgressIndicator, | ||
}} | ||
> | ||
<Input onChange={({ target: { value } }) => setInputValue(value)} value={inputValue} /> | ||
</InputGroup> | ||
</> | ||
); | ||
}; |
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
18 changes: 2 additions & 16 deletions
18
packages/ui/src/components/progress-indicator/progress-indicator.types.ts
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 |
---|---|---|
@@ -1,17 +1,3 @@ | ||
import { HTMLAttributes } from 'react'; | ||
import { type VariantProps } from 'tailwind-variants'; | ||
import { IconProps } from '../icon/icon.types.js'; | ||
|
||
import { styles } from './progress-indicator.styles.js'; | ||
|
||
type Variants = VariantProps<typeof styles>; | ||
|
||
export type ProgressIndicatorProps = { | ||
/** | ||
* Whether indicator should be white for a dark background | ||
*/ | ||
inverted?: boolean; | ||
/** | ||
* Size of progress indicator | ||
*/ | ||
size?: Variants['size']; | ||
} & HTMLAttributes<Element>; | ||
export type ProgressIndicatorProps = IconProps; |