diff --git a/.changeset/lazy-timers-battle.md b/.changeset/lazy-timers-battle.md new file mode 100644 index 000000000..9b0e39b2e --- /dev/null +++ b/.changeset/lazy-timers-battle.md @@ -0,0 +1,5 @@ +--- +'@westpac/ui': minor +--- + +added new prop to popover components that makes trigger button look like inline link diff --git a/apps/site/src/components/code/code.inject-components.ts b/apps/site/src/components/code/code.inject-components.ts index 2305a13c7..21629e4f9 100644 --- a/apps/site/src/components/code/code.inject-components.ts +++ b/apps/site/src/components/code/code.inject-components.ts @@ -10,6 +10,8 @@ export { StaticCode } from '../static-code/index'; export { ComponentTitle } from '../document-renderer/component-title'; +export * from '../country-flags/index'; + export { Badge, Button, @@ -98,6 +100,8 @@ export { Heading, ProgressIndicator, BottomSheet, + Header, + Footer, } from '@westpac/ui'; export * from '@westpac/ui/icon'; diff --git a/apps/site/src/components/country-flags/afghanistan-flag.tsx b/apps/site/src/components/country-flags/afghanistan-flag.tsx new file mode 100644 index 000000000..67c3dbc9d --- /dev/null +++ b/apps/site/src/components/country-flags/afghanistan-flag.tsx @@ -0,0 +1,859 @@ +export function AfghanistanFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/andorra-flag.tsx b/apps/site/src/components/country-flags/andorra-flag.tsx new file mode 100644 index 000000000..0a8b211da --- /dev/null +++ b/apps/site/src/components/country-flags/andorra-flag.tsx @@ -0,0 +1,309 @@ +export function AndorraFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/antarctica-flag.tsx b/apps/site/src/components/country-flags/antarctica-flag.tsx new file mode 100644 index 000000000..fadcfcaf9 --- /dev/null +++ b/apps/site/src/components/country-flags/antarctica-flag.tsx @@ -0,0 +1,25 @@ +export function AntarcticaFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/ascension-island-flag.tsx b/apps/site/src/components/country-flags/ascension-island-flag.tsx new file mode 100644 index 000000000..bcbfeef7d --- /dev/null +++ b/apps/site/src/components/country-flags/ascension-island-flag.tsx @@ -0,0 +1,277 @@ +export function AscensionIslandFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/australia-flag.tsx b/apps/site/src/components/country-flags/australia-flag.tsx new file mode 100644 index 000000000..32bd36a61 --- /dev/null +++ b/apps/site/src/components/country-flags/australia-flag.tsx @@ -0,0 +1,27 @@ +export function AustraliaFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/cuba-flag.tsx b/apps/site/src/components/country-flags/cuba-flag.tsx new file mode 100644 index 000000000..e5d6d85c9 --- /dev/null +++ b/apps/site/src/components/country-flags/cuba-flag.tsx @@ -0,0 +1,26 @@ +export function CubaFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + + + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/france-flag.tsx b/apps/site/src/components/country-flags/france-flag.tsx new file mode 100644 index 000000000..7910cde73 --- /dev/null +++ b/apps/site/src/components/country-flags/france-flag.tsx @@ -0,0 +1,15 @@ +export function FranceFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/index.ts b/apps/site/src/components/country-flags/index.ts new file mode 100644 index 000000000..b2366c0dc --- /dev/null +++ b/apps/site/src/components/country-flags/index.ts @@ -0,0 +1,12 @@ +export { AfghanistanFlag } from './afghanistan-flag'; +export { AntarcticaFlag } from './antarctica-flag'; +export { CubaFlag } from './cuba-flag'; +export { IndiaFlag } from './india-flag'; +export { UnitedStatesFlag } from './united-states-flag'; +export { UnitedKingdomFlag } from './united-kingdom-flag'; +export { AndorraFlag } from './andorra-flag'; +export { UnitedArabEmiratesFlag } from './united-arab-emirates-flag'; +export { AscensionIslandFlag } from './ascension-island-flag'; +export { AustraliaFlag } from './australia-flag'; +export { NewZealandFlag } from './new-zealand-flag'; +export { FranceFlag } from './france-flag'; diff --git a/apps/site/src/components/country-flags/india-flag.tsx b/apps/site/src/components/country-flags/india-flag.tsx new file mode 100644 index 000000000..2bc160133 --- /dev/null +++ b/apps/site/src/components/country-flags/india-flag.tsx @@ -0,0 +1,147 @@ +export function IndiaFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/new-zealand-flag.tsx b/apps/site/src/components/country-flags/new-zealand-flag.tsx new file mode 100644 index 000000000..faf92e214 --- /dev/null +++ b/apps/site/src/components/country-flags/new-zealand-flag.tsx @@ -0,0 +1,104 @@ +export function NewZealandFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/united-arab-emirates-flag.tsx b/apps/site/src/components/country-flags/united-arab-emirates-flag.tsx new file mode 100644 index 000000000..751013e4c --- /dev/null +++ b/apps/site/src/components/country-flags/united-arab-emirates-flag.tsx @@ -0,0 +1,16 @@ +export function UnitedArabEmiratesFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/united-kingdom-flag.tsx b/apps/site/src/components/country-flags/united-kingdom-flag.tsx new file mode 100644 index 000000000..febdf5931 --- /dev/null +++ b/apps/site/src/components/country-flags/united-kingdom-flag.tsx @@ -0,0 +1,23 @@ +export function UnitedKingdomFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + + ); +} diff --git a/apps/site/src/components/country-flags/united-states-flag.tsx b/apps/site/src/components/country-flags/united-states-flag.tsx new file mode 100644 index 000000000..48c528374 --- /dev/null +++ b/apps/site/src/components/country-flags/united-states-flag.tsx @@ -0,0 +1,22 @@ +export function UnitedStatesFlag({ className = 'h-4 w-4' }: { className?: string }) { + return ( + + + + + + + + ); +} diff --git a/apps/site/src/content/design-system/components/flexi-cell/code/development-examples/content.mdoc b/apps/site/src/content/design-system/components/flexi-cell/code/development-examples/content.mdoc index 4db58662d..cd5f7bd5e 100644 --- a/apps/site/src/content/design-system/components/flexi-cell/code/development-examples/content.mdoc +++ b/apps/site/src/content/design-system/components/flexi-cell/code/development-examples/content.mdoc @@ -116,17 +116,7 @@ } before={ - - - - - + } dualAction @@ -143,26 +133,14 @@ - - - - - + } withBorder tag="a" href="#" > - - List Item - + List Item ``` @@ -210,7 +188,7 @@ } - topBadge={({ className }) => Corner flag} + topBadge={({ className }) => Corner flag} > MYER @@ -279,30 +257,30 @@ return ( <> {MOCK_ACCOUNTS.map(({ title, id, accounts }) => ( -
-

{title}

- {accounts.map(({ name, amount, number }) => ( - - - {amount} - - available $9,999 - - } - > - - {name} - - {number} - - ))} -
+
+

{title}

+ {accounts.map(({ name, amount, number }) => ( + + + {amount} + + available $9,999 + + } + > + + {name} + + {number} + + ))} +
))} ); @@ -375,11 +353,7 @@ tag="a" href="#" key={name} - before={ - - {initials} - - } + before={{initials}} after={ @@ -396,11 +370,7 @@ href="#" dualAction key={name} - before={ - - {initials} - - } + before={{initials}} after={ } />} > {name} @@ -427,14 +397,23 @@ { code: 'IN', name: 'India', + svg: ( + + ), }, { code: 'UK', name: 'United Kingdom', + svg: ( + + ), }, { code: 'USA', name: 'United States', + svg: ( + + ), }, ], }, @@ -444,19 +423,31 @@ payees: [ { code: 'AI', - name: 'Ascension Islands', + name: 'Ascension Island', + svg: ( + + ), }, { code: 'AN', name: 'Andorra', + svg: ( + + ), }, { code: 'UA', name: 'United Arab Emirates', + svg: ( + + ), }, { code: 'AF', name: 'Afghanistan', + svg: ( + + ), }, ], }, @@ -468,28 +459,14 @@

{title}

- {payees.map(({ name }) => { + {payees.map(({ name, svg }) => { return ( - - - - - - - } + before={{svg}} > {name} @@ -518,6 +495,9 @@ number: '10964567891', bank: 'BANK OF ANTARCTICA, ANTARCTICA', code: 'NFBKAS33XXX', + svg: ( + + ), }, { name: 'Joss Wight', @@ -525,6 +505,9 @@ number: '10964567892', bank: 'LLOYDS OF LONDON, DEVON', code: 'NFBKAS33XXX', + svg: ( + + ), }, ], }, @@ -538,6 +521,9 @@ bank: 'BANK OF AMERICA, NEW YORK', code: 'NFBKAS33XXX', paidAt: undefined, + svg: ( + + ), }, { initials: 'AC', @@ -546,6 +532,9 @@ bank: 'BANK OF AMERICA, NEW YORK', code: 'NFBKAS33XXX', paidAt: undefined, + svg: ( + + ), }, ], }, @@ -559,6 +548,9 @@ bank: 'BANK OF CUBA, HAVANA', code: 'NFBKAS33XXX', paidAt: undefined, + svg: ( + + ), }, ], }, @@ -569,27 +561,13 @@ {MOCK_FOREIGNPAYEES.map(({ title, id, payees }) => (

{title}

- {payees.map(({ name, number, paidAt, bank, code }) => + {payees.map(({ name, number, paidAt, bank, code, svg }) => paidAt ? ( - - - - - - - } + before={{svg}} after={ @@ -610,17 +588,7 @@ key={name} before={ - - - - - + {svg} } after={ } />} @@ -673,11 +641,7 @@ } - topBadge={({ className }) => ( - - Corner flag - - )} + topBadge={({ className }) => Corner flag} > MYER @@ -725,11 +689,7 @@ href="#" tag="a" withBorder - topBadge={({ className }) => ( - - Corner flag - - )} + topBadge={({ className }) => Corner flag} > - - - } - after={ - - Completed - - } - > - - - {title} - - {subtitle} - - - - - } - after={ - - Completed - - } - > - - - {title} - - {subtitle} - + tag="a" + href="#" + withBorder + withArrow + key={title} + before={ + + + + } + after={ + + Completed + + } + > + + + {title} + + {subtitle} + + + + + } + after={ + + Completed + + } + > + + + {title} + + {subtitle} + ); }; diff --git a/apps/site/src/content/design-system/components/popover/code/development-examples/content.mdoc b/apps/site/src/content/design-system/components/popover/code/development-examples/content.mdoc index acf905137..f9876f2c4 100644 --- a/apps/site/src/content/design-system/components/popover/code/development-examples/content.mdoc +++ b/apps/site/src/content/design-system/components/popover/code/development-examples/content.mdoc @@ -21,3 +21,40 @@
``` + +### Popover with inline link styling + +```tsx +
+ <> +

Inside paragraph

+

+ {' '} + This is an example of using a popover as link.{' '} + + Click here. + {' '} + To test popover. +

+ + <> +

Inside hint

+ + {' '} + This is an example of using a popover as link.{' '} + + Click here. + +

+ } + > + +
+ +
+``` \ No newline at end of file diff --git a/packages/ui/src/components/input-group/input-group.styles.ts b/packages/ui/src/components/input-group/input-group.styles.ts index 61012617b..d6c30e1ac 100644 --- a/packages/ui/src/components/input-group/input-group.styles.ts +++ b/packages/ui/src/components/input-group/input-group.styles.ts @@ -1,6 +1,5 @@ import { tv } from 'tailwind-variants'; -const inlineFlexInput = { input: 'inline-flex' }; export const styles = tv( { slots: { @@ -27,18 +26,20 @@ export const styles = tv( // Has to be done this as doing it with compoundVariants with array was not working width: { full: '', - 1: inlineFlexInput, - 2: inlineFlexInput, - 3: inlineFlexInput, - 4: inlineFlexInput, - 5: inlineFlexInput, - 6: inlineFlexInput, - 7: inlineFlexInput, - 8: inlineFlexInput, - 9: inlineFlexInput, - 10: inlineFlexInput, - 20: inlineFlexInput, - 30: inlineFlexInput, + // Below ignored because tailwind was showing a transform error when using a const + // eslint-disable-next-line sonarjs/no-duplicate-string + 1: { input: 'inline-flex' }, + 2: { input: 'inline-flex' }, + 3: { input: 'inline-flex' }, + 4: { input: 'inline-flex' }, + 5: { input: 'inline-flex' }, + 6: { input: 'inline-flex' }, + 7: { input: 'inline-flex' }, + 8: { input: 'inline-flex' }, + 9: { input: 'inline-flex' }, + 10: { input: 'inline-flex' }, + 20: { input: 'inline-flex' }, + 30: { input: 'inline-flex' }, }, }, compoundVariants: [ diff --git a/packages/ui/src/components/popover/popover.component.tsx b/packages/ui/src/components/popover/popover.component.tsx index f274bb4c5..2bfe6ce65 100644 --- a/packages/ui/src/components/popover/popover.component.tsx +++ b/packages/ui/src/components/popover/popover.component.tsx @@ -25,11 +25,13 @@ export function Popover({ look, soft = false, open = false, + linkStyling = false, + size = 'medium', icon, }: PopoverProps) { const state = useOverlayTriggerState({}); const panelId = useId(); - const styles = popoverStyles({}); + const styles = popoverStyles({ linkStyling }); const ref = useRef(null); const handleClick = useCallback(() => { @@ -57,13 +59,15 @@ export function Popover({ return (
diff --git a/packages/ui/src/components/popover/popover.stories.tsx b/packages/ui/src/components/popover/popover.stories.tsx index 86e01e92b..6409295e1 100644 --- a/packages/ui/src/components/popover/popover.stories.tsx +++ b/packages/ui/src/components/popover/popover.stories.tsx @@ -1,6 +1,8 @@ import { type Meta, StoryFn, type StoryObj } from '@storybook/react'; +import { Field } from '../field/field.component.js'; import { HelpIcon } from '../icon/index.js'; +import { Input } from '../input/input.component.js'; import { Popover } from './popover.component.js'; @@ -66,6 +68,38 @@ export const NoHeading: Story = { }, }; +/** + * > Popover trigger as inline link appearance + */ +export const AsInlineLinkAppearance = () => ( + <> +

Inside paragraph

+

+ {' '} + This is an example of using a popover that looks like an inline link.{' '} + + Click here. + {' '} + To test popover. +

+

Inside hint

+ + {' '} + This is an example of using a popover that looks like an inline link.{' '} + + Click here. + +

+ } + > + +
+ +); + /** * > Auto adjustment NOTE: Does not display correctly in story view please check individual story */ diff --git a/packages/ui/src/components/popover/popover.styles.ts b/packages/ui/src/components/popover/popover.styles.ts index 6ab9bf998..493641592 100644 --- a/packages/ui/src/components/popover/popover.styles.ts +++ b/packages/ui/src/components/popover/popover.styles.ts @@ -4,8 +4,16 @@ export const styles = tv( { slots: { base: 'relative inline-block', + button: '', + }, + variants: { + linkStyling: { + true: { + button: 'p-0', + }, + false: {}, + }, }, - variants: {}, }, { responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] }, ); diff --git a/packages/ui/src/components/popover/popover.types.ts b/packages/ui/src/components/popover/popover.types.ts index 14734e22b..eb7fccf16 100644 --- a/packages/ui/src/components/popover/popover.types.ts +++ b/packages/ui/src/components/popover/popover.types.ts @@ -25,6 +25,10 @@ export type PopoverProps = { * Use an icon as the button */ icon?: (props: IconProps) => JSX.Element; + /** + * Removes padding from trigger button and sets look to link to be able to look inline, use size prop to match font size + */ + linkStyling?: boolean; /** * A function for the onClick event */ @@ -39,4 +43,4 @@ export type PopoverProps = { */ placement?: 'top' | 'bottom'; } & HTMLAttributes & - Pick; + Pick;