Repository navigation
feat(Alert): add maxHeight with show more toggle #1279
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
base: main
Are you sure you want to change the base?
Changes from all commits
081e3a3
c8be6c0
07bb24a
ef7572d
182d160
9d3d9ce
68815ed
ebca59d
ca3b277
caad91e
2910f38
61633ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@clickhouse/click-ui': minor | ||
| --- | ||
|
|
||
| `Alert` accepts `maxHeight` to cap its collapsed height and show a Show more / Show less toggle when the text overflows. Expanded, the alert fills the width and height of its container and the text scrolls inside it. Visual: unchanged unless `maxHeight` is set. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| /* stylelint-disable custom-property-pattern -- design tokens use camelCase (e.g. iconBackground) */ | ||
|
|
||
| .alert { | ||
| --alert-max-height: initial; | ||
|
|
||
| display: flex; | ||
| width: 100%; | ||
| overflow: hidden; | ||
|
|
@@ -10,6 +12,18 @@ | |
| color: var(--click-alert-color-text-neutral); | ||
| } | ||
|
|
||
| .alert_max-height { | ||
| max-height: var(--alert-max-height, none); | ||
| } | ||
|
|
||
| /* Expanded lifts the collapsed cap and fills the parent. The text then scrolls. */ | ||
| .alert_max-height.alert_expanded { | ||
| height: 100%; | ||
| min-height: 0; | ||
| max-height: none; | ||
| flex: 1 1 auto; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expanding drops the height capHigh Severity Expanding applies Additional Locations (1)Reviewed by Cursor Bugbot for commit ca3b277. Configure here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| .alert_type_default { | ||
| justify-content: start; | ||
| border-radius: var(--click-alert-radii-end); | ||
|
|
@@ -175,3 +189,83 @@ | |
| color: inherit; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .alert__toggle { | ||
| margin: var(--click-container-gap-xxs) 0 0; | ||
| padding: 0; | ||
| flex-shrink: 0; | ||
| align-self: flex-start; | ||
| border: none; | ||
| background-color: transparent; | ||
| color: inherit; | ||
| text-decoration: underline; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .alert__toggle:focus-visible { | ||
| outline: 2px solid var(--click-global-color-outline-default); | ||
| outline-offset: 1px; | ||
| } | ||
|
|
||
| .alert__toggle_size_small { | ||
| font: var(--click-alert-small-typography-text-default); | ||
| } | ||
|
|
||
| .alert__toggle_size_medium { | ||
| font: var(--click-alert-medium-typography-text-default); | ||
| } | ||
|
|
||
| /* Height cap. Lives after the base rules so these selectors do not precede lower-specificity ones. */ | ||
| .alert_max-height .alert__text-wrapper { | ||
| min-width: 0; | ||
| min-height: 0; | ||
| } | ||
|
|
||
| .alert_max-height.alert_expanded .alert__text-wrapper { | ||
| min-width: 0; | ||
| min-height: 0; | ||
| overflow: hidden; | ||
| flex: 1 1 auto; | ||
| } | ||
|
|
||
| .alert_max-height .alert__title { | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| /* stylelint-disable plugin/no-unsupported-browser-features, property-no-vendor-prefix -- Chrome below 120 and Safari below 15.4 only know the prefixed mask, and the build has no autoprefixer */ | ||
| .alert_max-height .alert__text { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| /* Only the alpha channel matters, so a system color stands in for a literal one. */ | ||
| --alert-fade: linear-gradient( | ||
| to bottom, | ||
| canvastext calc(100% - var(--click-container-space-sm)), | ||
| transparent | ||
| ); | ||
|
|
||
| min-height: 0; | ||
| overflow: hidden; | ||
| -webkit-mask-image: var(--alert-fade); | ||
| mask-image: var(--alert-fade); | ||
| scroll-behavior: auto; | ||
| } | ||
|
|
||
| .alert_max-height .alert__text_expanded { | ||
| width: 100%; | ||
| min-width: 0; | ||
| min-height: 0; | ||
| overflow: auto; | ||
| flex: 1 1 auto; | ||
| align-self: stretch; | ||
| } | ||
|
|
||
| .alert_max-height .alert__text_no-fade { | ||
| -webkit-mask-image: none; | ||
| mask-image: none; | ||
| } | ||
|
|
||
| @media (forced-colors: active) { | ||
| .alert_max-height .alert__text { | ||
| -webkit-mask-image: none; | ||
| mask-image: none; | ||
| } | ||
| } | ||
| /* stylelint-enable plugin/no-unsupported-browser-features, property-no-vendor-prefix */ | ||




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.
Can we instead go with
max-height: 100%instead ofheight: 100%; flex: 1 1 autowhile expanded?what happens - after Show more activation, the alert grows until nothing overflows, so the toggle unmounts in the same click and focus falls to body.
Note that test would also require changes.