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(ColorsGrid): add ColorsGrid component #1178

Closed
wants to merge 1 commit into from
Closed

Conversation

aulian0v
Copy link
Contributor

@aulian0v aulian0v commented Dec 1, 2023

No description provided.

@gravity-ui-bot
Copy link
Contributor

Playwright Test Component is ready.

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@@ -0,0 +1,85 @@
@use '../variables';

$block: '.#{variables.$ns}colors-grid';
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 $ns-new for newer components

Comment on lines 6 to 8
--yc-color-size: 28px;
--yc-color-icon-size: 12px;
--yc-color-gap: 1px;
Copy link
Contributor

Choose a reason for hiding this comment

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

If these are considered public, then please follow this pattern for variables


width: min-content;
display: grid;
grid-template-columns: repeat(var(--cols-num), 1fr);
Copy link
Contributor

Choose a reason for hiding this comment

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

"private" vars should starts with --_--

&__check {
width: var(--yc-color-icon-size);
height: var(--yc-color-icon-size);
z-index: 1;
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 these z-index: 1 through the 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.

So that the hover styles of the next element do not overlap with this one

@@ -0,0 +1,82 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

What about changing name to the ColorPalette?

export interface ColorsGridProps extends DOMProps, QAProps {
colors: Color[];
value?: string;
rowSize?: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add rows, columns props to separately configure grid?

return (
<div
key={index}
data-value={item.value}
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need data-attributes. Instead we can pass the value directly to the onClick handler

key={index}
data-value={item.value}
role={isClickable ? 'button' : undefined}
tabIndex={isClickable ? 0 : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the component's keyborad interaction should be the same as in radiogroups. It can also use radio inputs for "native" interactions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my case, a request is sent when choosing a color. Native navigation will cause a lot of queries

{value: 'color_12', color: '#52A6C5'},
];

const DefaultTemplate: StoryFn<ColorsGridProps> = (args) => {
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 newer story syntax. See example in Button

element.style.color = color;
document.body.appendChild(element);

const computedColor = window.getComputedStyle(element).color;
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 can't use elements from the component itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is necessary to calculate the color before the first display of the elements. Doing this in useEffect after the first render doesn't seem like a good idea

@amje
Copy link
Contributor

amje commented May 7, 2024

You can now use the Palette component for such purposes

@amje amje closed this May 7, 2024
@amje amje deleted the feat/colors-grid branch July 16, 2024 15:55
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.

3 participants