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/pure cell different clickable areas #1177

Merged
merged 8 commits into from
Apr 27, 2024

Conversation

FominSergey5869
Copy link
Contributor

Опишите проблему

Необходимо было добавить разные кликабельные области для PureCell.

Дизайн https://www.figma.com/file/xsWJdFDoAyA8VkbuMxP4yR/Web-%3A%3A-Core-Wrappers?type=design&node-id=0-1&mode=design&t=vQhXj8io04PKwbws-0

Шаги для воспроизведения

Добавить onClick для Graphic Main Addon FooterButton и PureCelll

Ожидаемое поведение

При нажатии на кликабельную область стработает только обрабочик этой области ( при наличии пропса onClick у PureCell ), hover и active состояния воспроизводятся только у кликабельной области. При взаимодействии со всей PureCell ячейкой, hover и active состояния воспроизводятся на всей ячейке ( при наличии пропса onClick у PureCell )

Copy link

changeset-bot bot commented Apr 23, 2024

🦋 Changeset detected

Latest commit: 2b48e69

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@alfalab/core-components-themes Patch
@alfalab/core-components-pure-cell Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls
Copy link

coveralls commented Apr 23, 2024

Pull Request Test Coverage Report for Build 8859001993

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 38 of 53 (71.7%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 84.318%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/pure-cell/src/components/addon/component.tsx 6 9 66.67%
packages/pure-cell/src/components/graphics/component.tsx 6 9 66.67%
packages/pure-cell/src/components/main/component.tsx 11 14 78.57%
packages/pure-cell/src/components/footer-button/component.tsx 7 13 53.85%
Totals Coverage Status
Change from base Build 8800931717: -0.3%
Covered Lines: 9505
Relevant Lines: 10406

💛 - Coveralls

@core-ds-bot
Copy link
Collaborator

Собрана новая демка.

@SiebenSieben
Copy link
Contributor

Нужно добавить changeset


const setHover = () => setHoverState(true);
const unsetHover = () => setHoverState(false);
const setActive = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Здесь также можно написать в одну строку
const setActive = () => setActiveState(true);

}) => {
const pureCellContext = useContext(PureCellContext);

const Component = onClick ? 'button' : 'section';
Copy link
Contributor

Choose a reason for hiding this comment

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

Строковые литералы ('button', 'section') не должны быть разбросаны по документу, а объявлены в какой либо сущности (enum, object, map). В других файлах поправить аналогичным образом.

@@ -120,11 +123,37 @@ const PureCellComponent = forwardRef<HTMLElement, PureCellProps>(
) => {
const cellRef = useRef<HTMLDivElement>(null);
const [focused] = useFocus(cellRef, 'keyboard');
const [hoverState, setHoverState] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Желательно указывать дженерики useState<boolean>

}) => {
const pureCellContext = useContext(PureCellContext);

const Component = onClick ? 'button' : 'section';

const events = onClick
Copy link
Contributor

Choose a reason for hiding this comment

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

Тут можно убрать проверку, и сделать объект onClickEvents. А саму проверку делать уже в spread операторе {...(onClick && { onClickEvents })}
Подобное встречается несколько раз по коду, в целом на твое усмотрение. Можно оставить и так, но если количество эвентов в будущем изменится придется переписать тернарник.

) => {
(
onMouseEnter as
| React.MouseEventHandler<HTMLAnchorElement>
Copy link
Contributor

Choose a reason for hiding this comment

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

Дублирование типов, React.MouseEventHandler<HTMLAnchorElement> React.MouseEventHandler<HTMLButtonElement>. Может быть вынесем в рамках файла?

@fulcanellee fulcanellee self-requested a review April 24, 2024 06:53
@Oladii
Copy link
Contributor

Oladii commented Apr 24, 2024

а можно изолировать поведение с опрозрачниванием при ховере и нажатии? В темах отличных от АО это не нужно. Если бы прозрачность изменялась только в теме клик — было-бы топчик

@core-ds-bot
Copy link
Collaborator

Собрана новая демка.

@FominSergey5869
Copy link
Contributor Author

Вынес в переменные в тему клика опасити для hover/active

@core-ds-bot
Copy link
Collaborator

Собрана новая демка.

@core-ds-bot
Copy link
Collaborator

Собрана новая демка.


Добавлена пропс onClick для компонента PureCell.Graphics
Добавлена пропс onClick для компонента PureCell.Main
Добавлена пропс onClick для компонента PureCell.Addon
Copy link
Collaborator

Choose a reason for hiding this comment

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

нужно добавить дефис в начало каждой строки
https://core-ds.github.io/core-components/master/?path=/docs/instructions-contributing--docs

@core-ds-bot
Copy link
Collaborator

Собрана новая демка.

@Valeri8888 Valeri8888 merged commit ffb6f8e into master Apr 27, 2024
7 checks passed
@Valeri8888 Valeri8888 deleted the feat/pure-cell_different_clickable_areas branch April 27, 2024 12:44
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.

None yet

7 participants