-
Notifications
You must be signed in to change notification settings - Fork 17
feat(Versions): redesign #2707
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
Merged
Merged
feat(Versions): redesign #2707
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,12 +19,16 @@ const MAX_DISPLAYED_VERSIONS = TRUNCATION_THRESHOLD - 1; | |
| const HOVER_DELAY = 200; | ||
| const TOOLTIP_OPEN_DELAY = 200; | ||
|
|
||
| type VersionsBarSize = 's' | 'm'; | ||
|
|
||
| interface VersionsBarProps { | ||
| preparedVersions: PreparedVersion[]; | ||
| withTitles?: boolean; | ||
| size?: VersionsBarSize; | ||
| } | ||
|
|
||
| export function VersionsBar({preparedVersions}: VersionsBarProps) { | ||
| const shouldTruncateVersions = preparedVersions.length > TRUNCATION_THRESHOLD; | ||
| export function VersionsBar({preparedVersions, withTitles = true, size = 's'}: VersionsBarProps) { | ||
| const shouldTruncateVersions = preparedVersions.length > TRUNCATION_THRESHOLD && size === 's'; | ||
|
|
||
| const [hoveredVersion, setHoveredVersion] = React.useState<string | undefined>(); | ||
| const [allVersionsDisplayed, setAllVersionsDisplayed] = React.useState<boolean>(false); | ||
|
|
@@ -103,12 +107,12 @@ export function VersionsBar({preparedVersions}: VersionsBarProps) { | |
| }, [handleMouseEnter]); | ||
|
|
||
| const isDimmed = (version: string) => { | ||
| return hoveredVersion && hoveredVersion !== version; | ||
| return Boolean(hoveredVersion && hoveredVersion !== version); | ||
| }; | ||
|
|
||
| return ( | ||
| <Flex gap={2} direction={'column'} className={b(null)} wrap> | ||
| <Flex className={b('bar')} grow={1} gap={0.5}> | ||
| <Flex direction={'column'} className={b('bar-wrapper', {size})} wrap> | ||
| <Flex className={b('bar', {size})} grow={1}> | ||
| {displayedVersions.map((item) => ( | ||
| <Tooltip | ||
| key={item.version} | ||
|
|
@@ -119,54 +123,103 @@ export function VersionsBar({preparedVersions}: VersionsBarProps) { | |
| {item.version} | ||
| </React.Fragment> | ||
| } | ||
| placement={'top-start'} | ||
| placement={size === 'm' ? 'auto' : 'top-start'} | ||
| openDelay={TOOLTIP_OPEN_DELAY} | ||
| > | ||
| <span | ||
| onMouseEnter={() => { | ||
| handleMouseEnter(item.version); | ||
| }} | ||
| onMouseLeave={handleMouseLeave} | ||
| className={b('version', {dimmed: isDimmed(item.version)})} | ||
| className={b('version', {dimmed: isDimmed(item.version), size})} | ||
| style={{backgroundColor: item.color, width: `${item.value}%`}} | ||
| /> | ||
| </Tooltip> | ||
| ))} | ||
| </Flex> | ||
|
|
||
| <Flex gap={0.5} direction={'column'}> | ||
| {truncatedDisplayedVersions.map((item) => ( | ||
| <Tooltip | ||
| key={item.version} | ||
| content={i18n('tooltip_nodes', {count: item.count})} | ||
| placement={'bottom-end'} | ||
| openDelay={TOOLTIP_OPEN_DELAY} | ||
| > | ||
| <Flex gap={1} alignItems={'center'} className={b('titles-wrapper')}> | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width="6" | ||
| height="6" | ||
| viewBox="0 0 6 6" | ||
| fill="none" | ||
| className={b('version-icon', {dimmed: isDimmed(item.version)})} | ||
| > | ||
| <circle cx="3" cy="3" r="3" fill={item.color} /> | ||
| </svg> | ||
| <div | ||
| className={b('title', {dimmed: isDimmed(item.version)})} | ||
| onMouseEnter={() => { | ||
| handleMouseEnter(item.version); | ||
| }} | ||
| onMouseLeave={handleMouseLeave} | ||
| > | ||
| {item.version} | ||
| </div> | ||
| </Flex> | ||
| </Tooltip> | ||
| ))} | ||
| <Flex>{renderButton()}</Flex> | ||
| </Flex> | ||
| {withTitles && ( | ||
| <Flex className={b('titles-wrapper', {size})}> | ||
| {truncatedDisplayedVersions.map((item) => ( | ||
| <VersionTitle | ||
| key={item.version} | ||
| version={item.version} | ||
| color={item.color || ''} | ||
| count={item.count} | ||
| isDimmed={isDimmed(item.version)} | ||
| onMouseEnter={() => { | ||
| handleMouseEnter(item.version); | ||
| }} | ||
| onMouseLeave={handleMouseLeave} | ||
| size={size} | ||
| /> | ||
| ))} | ||
| <Flex>{renderButton()}</Flex> | ||
| </Flex> | ||
| )} | ||
| </Flex> | ||
| ); | ||
| } | ||
|
|
||
artemmufazalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| interface VersionTitleProps { | ||
| version: string; | ||
| color: string; | ||
| count?: number; | ||
| isDimmed: boolean; | ||
| onMouseEnter: () => void; | ||
| onMouseLeave: () => void; | ||
|
||
| size: VersionsBarSize; | ||
| } | ||
|
|
||
| function VersionTitle({ | ||
| version, | ||
| color, | ||
| count, | ||
| isDimmed, | ||
| onMouseEnter, | ||
| onMouseLeave, | ||
| size, | ||
| }: VersionTitleProps) { | ||
| return ( | ||
| <Tooltip | ||
| content={i18n('tooltip_nodes', {count: count})} | ||
| placement={'bottom-end'} | ||
| openDelay={TOOLTIP_OPEN_DELAY} | ||
| > | ||
| <Flex alignItems={'center'} className={b('title', {size})}> | ||
| <VersionCircle size={size} dimmed={isDimmed} color={color} /> | ||
| <div | ||
| className={b('title-text', {dimmed: isDimmed, size})} | ||
| onMouseEnter={onMouseEnter} | ||
| onMouseLeave={onMouseLeave} | ||
| > | ||
| {version} | ||
| </div> | ||
| </Flex> | ||
| </Tooltip> | ||
| ); | ||
| } | ||
|
|
||
artemmufazalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| interface VersionCircleProps { | ||
| size: VersionsBarSize; | ||
| dimmed: boolean; | ||
| color: string; | ||
| } | ||
|
|
||
| function VersionCircle({size, dimmed, color}: VersionCircleProps) { | ||
| const numericSize = size === 'm' ? 8 : 6; | ||
| const radius = numericSize / 2; | ||
|
|
||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={numericSize} | ||
| height={numericSize} | ||
| viewBox={`0 0 ${numericSize} ${numericSize}`} | ||
| fill="none" | ||
| className={b('version-icon', {dimmed})} | ||
| > | ||
| <circle cx={radius} cy={radius} r={radius} fill={color} /> | ||
| </svg> | ||
| ); | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
42 changes: 2 additions & 40 deletions
42
src/containers/Versions/GroupedNodesTree/GroupedNodesTree.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,15 @@ | ||
| @use '../../../styles/mixins.scss'; | ||
|
|
||
| .ydb-versions-grouped-node-tree { | ||
| $item-width: 100%; | ||
| $margin-size: 24px; | ||
|
|
||
| &_first-level { | ||
| margin-top: 10px; | ||
| margin-bottom: 10px; | ||
|
|
||
| &__wrapper { | ||
| border: 1px solid var(--g-color-line-generic); | ||
| border-radius: 10px; | ||
| border-radius: var(--g-border-radius-m); | ||
| } | ||
|
|
||
| &__dt-wrapper { | ||
| position: relative; | ||
| z-index: 0; | ||
|
|
||
| overflow: auto hidden; | ||
|
|
||
| margin-right: $margin-size; | ||
| margin-left: $margin-size; | ||
| } | ||
|
|
||
| .ydb-tree-view { | ||
| @include mixins.body-2-typography(); | ||
|
|
||
| // Apply margin ignoring first element of the tree | ||
| .ydb-tree-view { | ||
| margin-left: $margin-size; | ||
| } | ||
| } | ||
|
|
||
| & .tree-view_item { | ||
| height: 40px; | ||
| margin: 0; | ||
|
|
||
| // By default tree is rendered with padding calculated based on level | ||
| // We replace padding with margin for correct hover | ||
| padding: 0 10px !important; | ||
|
|
||
| border: 0; | ||
| border-radius: 10px; | ||
| } | ||
|
|
||
| & .tree-view_children .tree-view_item { | ||
| width: $item-width; | ||
| } | ||
|
|
||
| & .g-progress__stack { | ||
| cursor: pointer; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderButton renders one element - why do we need Flex here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's needed to limit button width. Replaced it with css
width: max-content