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

develop #1

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

develop #1

wants to merge 28 commits into from

Conversation

falconx
Copy link
Owner

@falconx falconx commented Sep 4, 2022

No description provided.

@vercel
Copy link

vercel bot commented Sep 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
trello ✅ Ready (Inspect) Visit Preview Sep 6, 2022 at 9:43AM (UTC)

}

// https://itnext.io/react-polymorphic-components-with-typescript-f7ce72ea7af2
const VisuallyHidden = <T extends React.ElementType = 'div'>({ as, ...props }: VisuallyHiddenProps<T> & Omit<React.ComponentPropsWithoutRef<T>, keyof VisuallyHiddenProps<T>>) => {
Copy link
Owner Author

@falconx falconx Sep 5, 2022

Choose a reason for hiding this comment

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

Accessibility component for visually hiding elements and ensuring they're still available within the accessibility tree.

Polymorphic component to allow for consumers of the component to specify the HTML Element to render whilst retaining TS support for that element's props/attributes.

Example usage:

<VisuallyHidden as="label" htmlFor="some-id">Example</VisuallyHidden>

This allows us to visually hide elements where a div is not permitted, for example a child element of a Paragraph element, whilst also helping to keep the DOM tree minimal.

@@ -0,0 +1,36 @@
import { useState } from 'react';

const useLocalStorage = <T>(key: string, initialValue: T) => {
Copy link
Owner Author

Choose a reason for hiding this comment

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

Designed to be used in the same was as React.useState.

Comment on lines +22 to +55
const defaultState: GlobalState = {
columns: [
{
id: 'todo',
title: 'To Do',
},
{
id: 'in-progress',
title: 'In Progress',
},
{
id: 'done',
title: 'Done',
},
],
cards: [
{
id: 'card-0',
columnId: 'done',
title: 'Make breakfast',
description: `In order to make breakfast you'll need the following ingredients:\n\n* Eggs\n* Sausages\n* Beans\n* Hash browns\n* Toast`,
},
{
id: 'card-1',
columnId: 'todo',
title: 'Check mail',
},
{
id: 'card-2',
columnId: 'todo',
title: 'Get to work',
},
],
};
Copy link
Owner Author

@falconx falconx Sep 5, 2022

Choose a reason for hiding this comment

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

Given that it's easy to clear the board, I figured it was nice to show the user a default example usage.

Comment on lines +17 to +26
let column;

column = await screen.findByText('To Do');
expect(column).toBeInTheDocument();

column = await screen.findByText('In Progress');
expect(column).toBeInTheDocument();

column = await screen.findByText('Done');
expect(column).toBeInTheDocument();
Copy link
Owner Author

Choose a reason for hiding this comment

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

Initially I wrote this as:

const headers = ['To Do', 'In Progress', 'Done'];

await Promise.all(headers.map(async (text) => {
  const column = await screen.findByText(text);
  expect(column).toBeInTheDocument();
}));

however, apart from being more difficult to read, a test failure would only report that the const column = await screen.findByText(text); line failed, and not which of the scenarios was to blame.

Comment on lines +55 to +62
<Column {...column}>
{cards.map(card => (
<Card
key={card.id}
{...card}
/>
))}
</Column>
Copy link
Owner Author

Choose a reason for hiding this comment

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

Component composition better than passing cards to Column

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant