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

feat: add DefinitionList #143

Merged
merged 11 commits into from
Mar 12, 2024
Merged

feat: add DefinitionList #143

merged 11 commits into from
Mar 12, 2024

Conversation

Raubzeug
Copy link
Contributor

@Raubzeug Raubzeug commented Feb 6, 2024

No description provided.

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@@ -0,0 +1,102 @@
@use '../variables';
@use '@gravity-ui/uikit/styles/mixins';
Copy link
Contributor

Choose a reason for hiding this comment

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

This works without ~ correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This syntax is used all over in the repo. No problem.

gap: 4px;

& + & {
margin-top: 16px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
margin-top: 16px;
margin-top: var(--g-spacing-4);

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally no purpose. Artefact crawled into PR.

@amje
Copy link
Contributor

amje commented Feb 29, 2024

Copy button not consistent. Let's fix it at the top right corner

Снимок экрана 2024-02-29 в 15 28 31 Снимок экрана 2024-02-29 в 15 29 01

@amje
Copy link
Contributor

amje commented Feb 29, 2024

Copy button not accessible from keyboard untill shown


#{$block}__copy-button {
inset-block-start: 0;
background-color: var(--g-color-base-background);
Copy link
Contributor

Choose a reason for hiding this comment

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

There is CSS API of Button to customize styling

Copy link
Contributor

Choose a reason for hiding this comment

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

No update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated it, the new version is on Files changed tab.

Comment on lines 108 to 112
color: var(--g-color-text-secondary);

&:hover {
color: var(--g-color-text-primary);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why default Button's views not work for this component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why I decided to do it...

Copy link
Contributor

Choose a reason for hiding this comment

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

No update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated it, the new version is on Files changed tab.

src/components/DefinitionList/DefinitionList.tsx Outdated Show resolved Hide resolved
src/components/DefinitionList/DefinitionList.tsx Outdated Show resolved Hide resolved
src/components/DefinitionList/DefinitionList.tsx Outdated Show resolved Hide resolved
src/components/DefinitionList/DefinitionList.tsx Outdated Show resolved Hide resolved
src/components/DefinitionList/DefinitionList.tsx Outdated Show resolved Hide resolved
src/components/DefinitionList/DefinitionList.tsx Outdated Show resolved Hide resolved
src/components/DefinitionList/DefinitionList.tsx Outdated Show resolved Hide resolved
return (
<dl className={b({responsive}, className)} role="list">
{items.map(({name, href, content, title, copyText, note, key, multilineName}) => {
const term = href ? <Link href={href}>{name}</Link> : name;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of having href prop we allow name to be ReactNode to render whatever user want?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like it! But in this case key property should be required.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can generate them by ourselves


export interface DefinitionListItem {
name: React.ReactNode;
key: string | number;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we need key?

Copy link
Contributor

Choose a reason for hiding this comment

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

Commented on above statement

name: React.ReactNode;
key: string | number;
content?: React.ReactNode;
title?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe split into 2 props, for name and for content?

}

if (typeof note === 'object') {
noteElement = <HelpPopover className={popoverClassName} {...note} />;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also set default placement here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why do you think we need it? <Popover> under the hood has default placement and it seems it is enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then why we set placement when note is a string?

noteElement = (
<HelpPopover
className={popoverClassName}
htmlContent={note}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use normal content props, not html

| key | `String \| Number` | true | | Item key |
| content | `ReactNode` | | | Definition |
| title | `String` | | | Title for definition. If not set, `content` value will be used |
| copyText | `String` | | | If set, it will be shown icon for copy this text |
Copy link
Contributor

Choose a reason for hiding this comment

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

String with lower "s"

@Raubzeug Raubzeug merged commit 3db3bbf into main Mar 12, 2024
3 checks passed
@Raubzeug Raubzeug deleted the add-definition-list branch March 12, 2024 11:14
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.

4 participants