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

Add StaticList to lab #4194

Merged
merged 41 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
45b069d
base static list component
ThusharaJ07 Aug 12, 2024
485ba96
added pending case
ThusharaJ07 Aug 12, 2024
9b25223
added changeset
ThusharaJ07 Aug 12, 2024
f945438
review comments
ThusharaJ07 Aug 14, 2024
c1e9df1
Update packages/lab/stories/static-list/static-list.qa.stories.tsx
joshwooding Aug 14, 2024
9659a9a
lint fix
ThusharaJ07 Aug 14, 2024
b2485c7
site example changes
ThusharaJ07 Aug 19, 2024
95c65c0
changed examples for static list
ThusharaJ07 Aug 20, 2024
15f2f4a
design review alignemnet
ThusharaJ07 Aug 21, 2024
5d7fa45
design review fix spacing and typograpgy
ThusharaJ07 Aug 22, 2024
755ae61
adding accessibility docs and change examples
ThusharaJ07 Aug 23, 2024
1bb0ec7
design review - accessibility doc section
ThusharaJ07 Aug 26, 2024
f618101
PR review comments
ThusharaJ07 Aug 29, 2024
6414e7f
PR review comments
ThusharaJ07 Aug 29, 2024
3e03539
accessibility doc changes
ThusharaJ07 Aug 29, 2024
6f3b72b
PR comments for gap and padding and divider composition
ThusharaJ07 Aug 29, 2024
8490869
lint
ThusharaJ07 Aug 30, 2024
903f7be
lint
ThusharaJ07 Aug 30, 2024
8bdfdc2
PR comments
ThusharaJ07 Sep 10, 2024
a0b4b62
PR comments
ThusharaJ07 Sep 10, 2024
1681f3d
lint
ThusharaJ07 Sep 10, 2024
a3b88dc
PR comments
ThusharaJ07 Sep 10, 2024
06a5a6a
PR comments
ThusharaJ07 Sep 10, 2024
a7cbb73
content component and pr comments
ThusharaJ07 Sep 12, 2024
a5d05c5
updated icon example desc
ThusharaJ07 Sep 12, 2024
1ca1855
updated accessibility
ThusharaJ07 Sep 16, 2024
8f2eda0
Update site/docs/components/static-list/usage.mdx
ThusharaJ07 Sep 17, 2024
2aaf3b2
Update site/docs/components/static-list/usage.mdx
ThusharaJ07 Sep 17, 2024
d348570
updated example PR comments
ThusharaJ07 Sep 17, 2024
6f0f2ee
Pr comment to add StaticListItemContent in docs
ThusharaJ07 Sep 25, 2024
efecad9
examples updates and accessibility
Fercas123 Sep 26, 2024
ea32109
clean
Fercas123 Oct 4, 2024
f10b82a
prettier
Fercas123 Oct 4, 2024
98c258b
Update packages/lab/stories/static-list/static-list.qa.stories.tsx
Fercas123 Oct 4, 2024
aa4447c
update from accessibility review
Fercas123 Oct 4, 2024
2bb4ffd
Update packages/lab/src/static-list/StaticList.tsx
Fercas123 Oct 4, 2024
23eeffd
fix prefix
Fercas123 Oct 4, 2024
67c5dc3
remove extra spacing
Fercas123 Oct 4, 2024
4bd82ce
button example to site
Fercas123 Oct 4, 2024
d25218e
hide decorative icons
Fercas123 Oct 4, 2024
54b4b70
silence dividers
Fercas123 Oct 4, 2024
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
20 changes: 20 additions & 0 deletions .changeset/added-static-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
"@salt-ds/lab": minor
---

Added `StaticList`, `StaticListItem`, `StaticListItemContent` component to lab.

```tsx
<StaticList>
<StaticListItem>
<StaticListItemContent>
<Text>New static list feature updates are available in lab</Text>
</StaticListItemContent>
</StaticListItem>
<StaticListItem>
<StaticListItemContent>
<Text>New static list feature updates are available in lab</Text>
</StaticListItemContent>
</StaticListItem>
</StaticList>
```
1 change: 1 addition & 0 deletions packages/lab/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export * from "./responsive";
export * from "./search-input";
export * from "./skip-link";
export * from "./slider";
export * from "./static-list";
export * from "./stepped-tracker";
export * from "./stepper-input";
export * from "./system-status";
Expand Down
3 changes: 3 additions & 0 deletions packages/lab/src/static-list/StaticList.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.saltStaticList {
overflow-y: auto;
}
37 changes: 37 additions & 0 deletions packages/lab/src/static-list/StaticList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { makePrefixer } from "@salt-ds/core";
import { useComponentCssInjection } from "@salt-ds/styles";
import { useWindow } from "@salt-ds/window";
import { clsx } from "clsx";
import {
type ComponentPropsWithoutRef,
type ReactNode,
forwardRef,
} from "react";

import staticListCss from "./StaticList.css";

const withBaseName = makePrefixer("saltStaticList");

export interface StaticListProps extends ComponentPropsWithoutRef<"ul"> {
/**
* The list items to be rendered within the StaticList.
*/
children: ReactNode;
}

export const StaticList = forwardRef<HTMLOListElement, StaticListProps>(
function StaticList({ children, className, ...rest }, ref) {
const targetWindow = useWindow();
useComponentCssInjection({
testId: "salt-static-list",
css: staticListCss,
window: targetWindow,
});

return (
<ol className={clsx(withBaseName(), className)} ref={ref} {...rest}>
{children}
</ol>
);
},
);
13 changes: 13 additions & 0 deletions packages/lab/src/static-list/StaticListItem.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.saltStaticListItem {
list-style-type: none;
display: flex;
gap: var(--salt-spacing-100);
box-sizing: border-box;
padding: var(--salt-spacing-50) var(--salt-spacing-100);
min-height: calc(var(--salt-size-base) + var(--salt-spacing-100));
}

.saltStaticListItem > .saltIcon {
/* Workaround to ensure the icon and button are aligned.*/
min-height: var(--salt-size-base);
Fercas123 marked this conversation as resolved.
Show resolved Hide resolved
}
30 changes: 30 additions & 0 deletions packages/lab/src/static-list/StaticListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { makePrefixer } from "@salt-ds/core";
import { useComponentCssInjection } from "@salt-ds/styles";
import { useWindow } from "@salt-ds/window";
import { clsx } from "clsx";
import { type ComponentPropsWithoutRef, forwardRef } from "react";

import staticListItemCss from "./StaticListItem.css";

const withBaseName = makePrefixer("saltStaticListItem");

export interface StaticListItemProps extends ComponentPropsWithoutRef<"li"> {}

export const StaticListItem = forwardRef<HTMLLIElement, StaticListItemProps>(
function StaticListItem(props, ref) {
const { className, children, ...restProps } = props;

const targetWindow = useWindow();
useComponentCssInjection({
testId: "salt-static-list-item",
css: staticListItemCss,
window: targetWindow,
});

return (
<li className={clsx(withBaseName(), className)} ref={ref} {...restProps}>
{children}
</li>
);
},
);
10 changes: 10 additions & 0 deletions packages/lab/src/static-list/StaticListItemContent.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.saltStaticListItemContent {
flex: 1 0;
margin: var(--salt-spacing-75) 0;
color: var(--salt-content-primary-foreground);
font-size: var(--salt-text-fontSize);
Fercas123 marked this conversation as resolved.
Show resolved Hide resolved
font-weight: var(--salt-text-fontWeight);
font-family: var(--salt-text-fontFamily);
line-height: var(--salt-text-lineHeight);
letter-spacing: var(--salt-text-letterSpacing);
}
39 changes: 39 additions & 0 deletions packages/lab/src/static-list/StaticListItemContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { makePrefixer } from "@salt-ds/core";
import { useComponentCssInjection } from "@salt-ds/styles";
import { useWindow } from "@salt-ds/window";
import { clsx } from "clsx";
import {
type ComponentPropsWithoutRef,
type ForwardedRef,
type ReactNode,
forwardRef,
} from "react";
import staticListItemContent from "./StaticListItemContent.css";

const withBaseName = makePrefixer("saltStaticListItemContent");

export interface StaticListItemContentProps
extends ComponentPropsWithoutRef<"div"> {
/**
* The content of Static List Item
*/
children?: ReactNode;
}

export const StaticListItemContent = forwardRef<
HTMLDivElement,
StaticListItemContentProps
>(function StaticListItemContent({ children, className, ...restProps }, ref) {
const targetWindow = useWindow();
useComponentCssInjection({
testId: "salt-static-list-item-content",
css: staticListItemContent,
window: targetWindow,
});

return (
<div className={clsx(withBaseName(), className)} {...restProps} ref={ref}>
{children}
</div>
);
});
3 changes: 3 additions & 0 deletions packages/lab/src/static-list/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./StaticList";
export * from "./StaticListItem";
export * from "./StaticListItemContent";
32 changes: 32 additions & 0 deletions packages/lab/stories/assets/exampleData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,35 @@ export const objectOptionsExampleData: objectOptionType[] = [
{ value: 30, text: "C Option", id: 3 },
{ value: 40, text: "D Option", id: 4 },
];

export const eventsData = [
"Team meeting",
"Meeting with John",
"Optional meeting",
"External meeting",
"Team lunch",
"Training event",
"Coffee break",
"Conference",
"Meeting with Jane",
];

export type ListEvent = {
title: string;
time: string;
link?: string;
};
export const complexEventsData = [
{ title: "Team meeting", time: "09:00 to 10:00", link: "#" },
{
title: "Meeting with John",
time: "10:00 to 11:00",
link: "#",
},
{
title: "Optional meeting",
time: "11:00 to 12:00",
link: "#",
},
{ title: "Team lunch", time: "12:00 to 13:00" },
];
148 changes: 148 additions & 0 deletions packages/lab/stories/static-list/static-list.qa.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import { Button, Divider, StackLayout, Text, useId } from "@salt-ds/core";
import { CalendarIcon, OverflowMenuIcon, VideoIcon } from "@salt-ds/icons";
import {
StaticList,
StaticListItem,
StaticListItemContent,
} from "@salt-ds/lab";
import type { Meta, StoryFn } from "@storybook/react";
import { clsx } from "clsx";
import { QAContainer, type QAContainerProps } from "docs/components";
import React, { Fragment } from "react";
import { complexEventsData, eventsData } from "../assets/exampleData";

export default {
title: "Lab/Static List/Static List QA",
component: StaticList,
} as Meta<typeof StaticList>;

export const AllExamples: StoryFn<QAContainerProps> = () => (
<QAContainer cols={4} width={1300} itemPadding={5} vertical transposeDensity>
<StaticList style={{ width: "320px" }}>
<StaticListItem>
<StaticListItemContent>Team meeting</StaticListItemContent>
</StaticListItem>
</StaticList>
<StaticList style={{ width: "320px" }}>
{eventsData.slice(0, 3).map((event, _index) => (
<StaticListItem key={event}>
<StaticListItemContent>
<Text>{event}</Text>
</StaticListItemContent>
</StaticListItem>
))}
</StaticList>
<StaticList style={{ width: "320px" }}>
{complexEventsData.map(({ title, time }) => (
<StaticListItem key={title}>
<StaticListItemContent>
<StackLayout gap={0.5}>
<Text color="inherit">{title}</Text>
<Text styleAs="label" color="secondary">
{time}
</Text>
</StackLayout>
</StaticListItemContent>
</StaticListItem>
))}
</StaticList>
<StaticList style={{ width: "320px" }}>
{complexEventsData.map(({ title, time }) => {
const id = useId();
return (
<StaticListItem key={title}>
<StaticListItemContent>
<StackLayout gap={0.5}>
<Text color="inherit" id={`label-${id}`}>
{title}
</Text>
<Text
styleAs="label"
color="secondary"
id={`secondary-label-${id}`}
>
{time}
</Text>
</StackLayout>
</StaticListItemContent>
<Button
id={`information-button-${id}`}
appearance="transparent"
aria-label="Zoom information"
aria-labelledby={clsx(
`label-${id}`,
`secondary-label-${id}`,
`information-button-${id}`,
)}
>
<VideoIcon aria-hidden />
</Button>
<Button
id={`options-button-${id}`}
appearance="transparent"
aria-label="More options"
aria-labelledby={clsx(
`label-${id}`,
`secondary-label-${id}`,
`options-button-${id}`,
)}
>
<OverflowMenuIcon aria-hidden />
</Button>
</StaticListItem>
);
})}
</StaticList>
<StaticList style={{ width: "320px" }}>
{complexEventsData.map(({ title, time }) => (
<StaticListItem key={title}>
<CalendarIcon aria-hidden />
<StaticListItemContent>
<StackLayout gap={0.5}>
<Text color="inherit">{title}</Text>
<Text styleAs="label" color="secondary">
{time}
</Text>
</StackLayout>
</StaticListItemContent>
</StaticListItem>
))}
</StaticList>
<StaticList style={{ width: "320px" }}>
{complexEventsData.map(({ title, time }, _index) => (
<Fragment key={title}>
<StaticListItem>
<StaticListItemContent>
<StackLayout gap={0.5}>
<Text color="inherit">{title}</Text>
<Text styleAs="label" color="secondary">
{time}
</Text>
</StackLayout>
</StaticListItemContent>
</StaticListItem>
{_index < complexEventsData.length - 1 && (
<Divider variant="tertiary" aria-hidden />
)}
</Fragment>
))}
</StaticList>
</QAContainer>
);

AllExamples.parameters = {
chromatic: {
disableSnapshot: false,
modes: {
theme: {
themeNext: "disable",
},
themeNext: {
themeNext: "enable",
corner: "rounded",
accent: "teal",
// Ignore headingFont given font is not loaded
},
},
},
};
Loading
Loading