Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/style fixes #916

Merged
merged 12 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ export function Sidebar({ items, brand }: SidebarProps) {
});

useEffect(() => {
if (!listRef.current) {
if (!outsideRef.current) {
return;
}
const listener = () => {
const y = listRef.current?.scrollTop || 0;
const y = outsideRef.current?.scrollTop || 0;
setScrolled(y > 0);
};
listRef.current.addEventListener('scroll', listener);
outsideRef.current.addEventListener('scroll', listener);
return () => {
listRef.current?.removeEventListener('scroll', listener);
outsideRef.current?.removeEventListener('scroll', listener);
};
}, [listRef]);
}, []);

useEffect(() => {
if (open) {
Expand Down Expand Up @@ -81,8 +81,8 @@ export function Sidebar({ items, brand }: SidebarProps) {
})}
>
<div
className={clsx({
'shadow-[rgba(0,0,0,0.26)_0_2px_5px]': scrolled,
className={clsx('sticky top-0 bg-white transition-shadow delay-0 duration-200 ease-[ease]', {
'shadow-[0_2px_5px_rgba(0,0,0,0.3)]': scrolled,
})}
>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
<span>Label</span>
</div>
</Button>
<a className="text-link underline" href="#">
Messages
<Badge color="muted" type="pill" className="ml-1">
<a className="text-link flex items-center" href="#">
<div className="underline">
Product feature
</div>
<Badge color="muted" type="pill" className="ml-1 no-underline">
12
</Badge>
</a>
Expand Down Expand Up @@ -65,12 +67,11 @@

<a className="text-link underline" href="#">
Product feature
<Badge color="muted" className="ml-1">
<Badge color="muted" className="ml-1">
NEW
</Badge>
</a>


</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ Badges come in 2 different styles: Default, used to highlight words, and Pill, u
<span>Label</span>
</div>
</Button>
<a className="text-link underline" href="#">
Messages
<a className="text-link flex items-center" href="#">
<div className="underline">
Messages
</div>
<Badge color="muted" type="pill" className="ml-1">
12
</Badge>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% shortCode name="where-is-this-available" /%}

{% availabilityContent
availableGel="available"
availableMesh="in-progress"
availableLegacyWdp="older-version-available" /%}
availableGel="available"
availableMesh="in-progress"
availableLegacyWdp="older-version-available" /%}
14 changes: 8 additions & 6 deletions packages/ui/src/components/badge/badge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ export const Soft = () => (
export const Links = () => (
<div className="flex flex-col gap-2">
{COLORS.map(color => (
<a key={color} className="text-link underline" href="#">
{color}
<Badge color={color} type="pill" className="ml-1">
12
</Badge>
</a>
<div key={color} className="flex items-center">
<a className="flex items-center text-link" href="#">
<div className="underline">Product feature</div>
<Badge color={color} type="pill" className="ml-1">
NEW
</Badge>
</a>
</div>
))}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/header/header.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const styles = tv(
largeLogo: 'max-sm:hidden',
leftContent: 'flex items-center',
leftButton:
'my-1 border-r border-[#E8E8ED] p-0 max-sm:-ml-2 max-sm:mr-2 max-sm:h-7 max-sm:min-w-[2.625rem] sm:-ml-4 sm:mr-3 sm:h-[3.3125rem] sm:min-w-[3.75rem]',
'my-1 border-r border-[#E8E8ED] p-0 rounded-none max-sm:-ml-2 max-sm:mr-2 max-sm:h-7 max-sm:min-w-[2.625rem] sm:-ml-4 sm:mr-3 sm:h-[3.3125rem] sm:min-w-[3.75rem]',
rightContent: 'ml-auto flex items-center',
},
variants: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,74 @@
import React from 'react';

import { Icon } from '../icon/icon.component.js';
import { Label } from '../label/label.component.js';

import { styles } from './progress-indicator.styles.js';
import { styles as ProgressIndicatorStyles } from './progress-indicator.styles.js';
import { ProgressIndicatorProps } from './progress-indicator.types.js';

export function ProgressIndicator({
className,
children,
color = 'hero',
inverted = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed revert back to color prop to be aligned with icon props

HZ991 marked this conversation as resolved.
Show resolved Hide resolved
label,
size = 'medium',
embedIcon: EmbedIcon,
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename this to just be icon: Icon to be consistent with how we take icons in other components

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is icon: EmbedIcon ok, it is just conflicting with the other 'Icon' import

className,
'aria-label': ariaLabel = 'Loading',
...props
}: ProgressIndicatorProps) {
const styles = ProgressIndicatorStyles({
size,
inverted,
});

const sizeMap: Record<string, { strokeWidth: number }> = {
xlarge: { strokeWidth: 4 },
large: { strokeWidth: 4 },
medium: { strokeWidth: 15 },
small: { strokeWidth: 20 },
xsmall: { strokeWidth: 30 },
};

const strokeHalfWidth = sizeMap[size.toString()].strokeWidth / 2;
const setPath = (
<g strokeWidth={strokeHalfWidth * 2}>
<>
<path
stroke="url(#a)"
d={`M ${strokeHalfWidth} 90 A ${90 - strokeHalfWidth} ${90 - strokeHalfWidth} 0 0 1 ${180 - strokeHalfWidth} 90`}
></path>
<path
stroke="url(#b)"
d={`M ${180 - strokeHalfWidth} 90 A ${90 - strokeHalfWidth} ${90 - strokeHalfWidth} 0 0 1 ${strokeHalfWidth} 90`}
></path>
</>
</g>
);

return (
<Icon className={styles({ className })} size={size} color={color} aria-label={ariaLabel} {...props}>
{children}
</Icon>
<div aria-label={ariaLabel} className={styles.container()}>
<div className="relative">
<Icon
viewBox="0 0 180 180"
fill="none"
color={inverted ? 'white' : 'hero'}
HZ991 marked this conversation as resolved.
Show resolved Hide resolved
className={styles.base({ className })}
{...props}
>
<defs>
<linearGradient id="a">
<stop offset="0%" stopOpacity="0" stopColor="currentColor"></stop>
<stop offset="100%" stopColor="currentColor"></stop>
</linearGradient>
<linearGradient id="b">
<stop offset="0%" stopColor="currentColor"></stop>
<stop offset="50%" stopColor="currentColor"></stop>
</linearGradient>
</defs>
{setPath}
</Icon>
{EmbedIcon && size === 'large' && <EmbedIcon size="large" className={styles.icon()} />}
HZ991 marked this conversation as resolved.
Show resolved Hide resolved
</div>
{label && size === 'large' && <Label className={styles.label()}>{label}</Label>}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Story = StoryObj<typeof meta>;
* >Default usage example
*/
export const Default: Story = {
args: { size: 'xlarge' },
args: { size: 'large' },
};

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { type Meta, StoryFn, type StoryObj } from '@storybook/react';

import { FingerprintIcon, PadlockIcon, PadlockTickIcon } from '../icon/index.js';

import { ProgressIndicator } from './progress-indicator.component.js';

const meta: Meta<typeof ProgressIndicator> = {
Expand All @@ -19,7 +21,7 @@ type Story = StoryObj<typeof meta>;
* > Default usage example
*/
export const Default: Story = {
args: { size: 'xlarge' },
args: { size: 'large' },
};

/**
Expand All @@ -28,11 +30,11 @@ export const Default: Story = {

export const Sizes = () => {
return (
<>
{(['xsmall', 'small', 'medium', 'large', 'xlarge'] as const).map(size => (
<ProgressIndicator key={size} size={size} className="mr-2" />
<div className="flex items-center justify-center gap-1">
{(['xsmall', 'small', 'medium', 'large'] as const).map(size => (
<ProgressIndicator key={size} size={size} />
))}
</>
</div>
);
};

Expand All @@ -42,10 +44,36 @@ export const Sizes = () => {

export const Inverted = () => {
return (
<div className="rounded bg-black">
{(['xsmall', 'small', 'medium', 'large', 'xlarge'] as const).map(size => (
<ProgressIndicator key={size} size={size} color={'white'} className="mr-2" />
<div className="flex items-center justify-center gap-1 rounded bg-black">
{(['xsmall', 'small', 'medium', 'large'] as const).map(size => (
<ProgressIndicator key={size} size={size} inverted />
))}
</div>
);
};

/**
* > Large indicator with embedded icon example
*/

export const Icon = () => {
return (
<div className="flex items-center justify-center gap-3">
<ProgressIndicator size="large" embedIcon={PadlockIcon} />
<ProgressIndicator size="large" embedIcon={PadlockTickIcon} />
<ProgressIndicator size="large" embedIcon={FingerprintIcon} />
</div>
);
};

/**
* > Large indicator with label example
*/
export const Label = () => {
return (
<div className="flex items-center justify-center gap-3">
<ProgressIndicator size="large" label="Loading..." />
<ProgressIndicator size="large" embedIcon={PadlockTickIcon} label="Signing in..." />
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,37 @@ import { tv } from 'tailwind-variants';

export const styles = tv(
{
base: 'box-border inline-block animate-[spin_0.7s_linear_infinite] rounded-full border border-r-0',
slots: {
icon: 'absolute inset-0 m-auto',
base: 'animate-[spin_0.7s_linear_infinite]',
container: 'flex flex-col items-center',
label: 'typography-body-9 mt-1.5',
},
variants: {
size: {
xsmall: { base: 'h-2 w-2' },
small: { base: 'h-3 w-3' },
medium: { base: 'h-4 w-4' },
large: { base: 'h-15 w-15' },
xlarge: { base: 'h-15 w-15' },
},
inverted: {
true: '',
false: '',
},
},
compoundSlots: [
HZ991 marked this conversation as resolved.
Show resolved Hide resolved
{
slots: ['icon', 'base', 'container'],
inverted: true,
class: ['text-white'],
},
{
slots: ['icon', 'base', 'container'],
inverted: false,
class: ['text-hero'],
},
],
},
{ responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
);
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
import { ReactNode } from 'react';

import { IconProps } from '../icon/icon.types.js';

export type ProgressIndicatorProps = IconProps;
export type ProgressIndicatorProps = IconProps & {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Update to Omit<IconProps, 'copyrightYear' | 'look'>

/**
* children prop
* @default false
*/
children?: ReactNode;
/**
* Icon embedded in progress indicator
*/
embedIcon?: (props: IconProps) => JSX.Element;
/**
* Progress indicator color
* @default false
*/
inverted?: boolean;
HZ991 marked this conversation as resolved.
Show resolved Hide resolved
/**
* Label placed below progress indicator
*/
label?: string;
};
2 changes: 1 addition & 1 deletion packages/ui/src/stories/foundation/typography.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const BrandFont = () => {
{ className: 'typography-brand-11', fontSize: fourteenPixel, lineHeight: twentyPixel },
];
return (
<Table>
<Table className="whitespace-pre">
<TableCaption>GEL brand typography tokens</TableCaption>
<TableHeader>
<TableHeaderRow>
Expand Down
Loading