-
Notifications
You must be signed in to change notification settings - Fork 79
feat(radio-button-group, segmented control): add validationMessage, validationIcon, and status properties #8561
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
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1f8f1b0
feat(radio-button-group): add validationMessage, validationIcon, and …
benelan 66e39b2
feat(segmented-control): add validationMessage, validationIcon, and s…
benelan a2c0786
chore: cleanup
benelan fb698ef
Merge remote-tracking branch 'origin/main' into benelan/radio-validat…
benelan 25dd6c8
chore: cleanup
benelan d5dfd37
chore: cleanup
benelan 3f41180
Merge remote-tracking branch 'origin/main' into benelan/radio-validat…
benelan 2c1f9c3
test: add properties to defaults/reflects
benelan 51bccc8
Merge remote-tracking branch 'origin/main' into benelan/radio-validat…
benelan 1e83a36
chore: clean
benelan 8a3914b
Merge branch 'main' into benelan/radio-validation-message
benelan a563d5f
chore: cleanup
benelan 3158a55
Merge remote-tracking branch 'origin/main' into benelan/radio-validat…
benelan 9cf25c1
chore: cleanup segmented-control styling
benelan a4a0687
fix(radio-group): spacing above validation message
benelan 8be513b
Merge remote-tracking branch 'origin/main' into benelan/radio-validat…
benelan 0bdf838
test(radio-button-group): separate validation-message into a NoTest s…
benelan 829acbd
Merge remote-tracking branch 'origin/main' into benelan/radio-validat…
benelan 2e8bfce
Merge remote-tracking branch 'origin/main' into benelan/radio-validat…
benelan 2dfb355
chore: cleanup
benelan f3c3955
chore: cleanup
benelan b3ebd59
Merge remote-tracking branch 'origin/main' into benelan/radio-validat…
benelan 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
37 changes: 28 additions & 9 deletions
37
packages/calcite-components/src/components/radio-button-group/radio-button-group.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,21 +1,40 @@ | ||
:host { | ||
@apply flex; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
:host > .item-wrapper { | ||
display: flex; | ||
max-inline-size: 100vw; | ||
} | ||
:host([layout="horizontal"]) { | ||
|
||
:host([layout="horizontal"]) > .item-wrapper { | ||
@apply flex-row flex-wrap; | ||
} | ||
:host([layout="horizontal"][scale="s"]) { | ||
@apply gap-4; | ||
|
||
:host([layout="horizontal"][scale="s"]) > .item-wrapper { | ||
@apply gap-x-4; | ||
} | ||
:host([layout="horizontal"][scale="m"]) { | ||
@apply gap-5; | ||
|
||
:host([layout="horizontal"][scale="m"]) > .item-wrapper { | ||
@apply gap-x-5; | ||
} | ||
:host([layout="horizontal"][scale="l"]) { | ||
@apply gap-6; | ||
|
||
:host([layout="horizontal"][scale="l"]) > .item-wrapper { | ||
@apply gap-x-6; | ||
} | ||
:host([layout="vertical"]) { | ||
|
||
:host([layout="vertical"]) > .item-wrapper { | ||
@apply flex-col; | ||
} | ||
|
||
:host([validation-message][layout="horizontal"]) > .item-wrapper { | ||
--calcite-label-margin-bottom: 0; | ||
} | ||
|
||
:host([validation-message][layout="vertical"]) > .item-wrapper > ::slotted(calcite-label:last-child) { | ||
--calcite-label-margin-bottom: 0; | ||
} | ||
|
||
@include form-validation-message(); | ||
@include base-component(); |
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,8 +1,8 @@ | ||
import { select } from "@storybook/addon-knobs"; | ||
import { boolean, storyFilters } from "../../../.storybook/helpers"; | ||
import { select, text } from "@storybook/addon-knobs"; | ||
import { boolean, iconNames, storyFilters } from "../../../.storybook/helpers"; | ||
import { modesDarkDefault } from "../../../.storybook/utils"; | ||
import readme from "./readme.md"; | ||
import { html } from "../../../support/formatting"; | ||
import readme from "./readme.md"; | ||
|
||
export default { | ||
title: "Components/Controls/Radio/Radio Button Group", | ||
|
@@ -19,6 +19,9 @@ export const simple = (): string => html` | |
${boolean("hidden", false)} | ||
layout="${select("layout", ["horizontal", "vertical"], "horizontal")}" | ||
scale="${select("scale", ["s", "m", "l"], "m")}" | ||
status="${select("status", ["idle", "invalid", "valid"], "idle")}" | ||
validation-icon="${select("validation-icon", ["", ...iconNames], "")}" | ||
validation-message="${text("validation-message", "")}" | ||
> | ||
<calcite-label layout="inline"> | ||
<calcite-radio-button value="react"></calcite-radio-button> | ||
|
@@ -44,13 +47,14 @@ export const darkModeRTL_TestOnly = (): string => html` | |
class="calcite-mode-dark" | ||
dir="rtl" | ||
name="dark" | ||
${boolean("disabled", false)} | ||
${boolean("hidden", false)} | ||
layout="${select("layout", ["horizontal", "vertical"], "horizontal")}" | ||
scale="${select("scale", ["s", "m", "l"], "m")}" | ||
layout="vertical" | ||
scale="l" | ||
status="valid" | ||
validation-icon | ||
validation-message="Thanks for not selecting Ember" | ||
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. 😭🔥 |
||
> | ||
<calcite-label layout="inline"> | ||
<calcite-radio-button value="react"></calcite-radio-button> | ||
<calcite-radio-button value="react" checked></calcite-radio-button> | ||
React | ||
</calcite-label> | ||
<calcite-label layout="inline"> | ||
|
@@ -69,3 +73,85 @@ export const darkModeRTL_TestOnly = (): string => html` | |
`; | ||
|
||
darkModeRTL_TestOnly.parameters = { modes: modesDarkDefault }; | ||
|
||
export const validationMessage_TestOnly = (): string => html` | ||
<style> | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
width: 400px; | ||
height: 200px; | ||
gap: 20px; | ||
} | ||
</style> | ||
<div class="container"> | ||
<calcite-radio-button-group | ||
layout="horizontal" | ||
name="validation" | ||
required | ||
scale="s" | ||
status="invalid" | ||
validation-icon | ||
validation-message="Please select an option." | ||
> | ||
<calcite-label layout="inline" scale="s"> | ||
<calcite-radio-button value="one" scale="s"></calcite-radio-button> | ||
One | ||
</calcite-label> | ||
<calcite-label layout="inline" scale="s"> | ||
<calcite-radio-button value="two" scale="s"></calcite-radio-button> | ||
Two | ||
</calcite-label> | ||
<calcite-label layout="inline" scale="s"> | ||
<calcite-radio-button value="three" scale="s"></calcite-radio-button> | ||
Three | ||
</calcite-label> | ||
</calcite-radio-button-group> | ||
|
||
<calcite-radio-button-group | ||
layout="horizontal" | ||
name="validation" | ||
required | ||
scale="m" | ||
status="invalid" | ||
validation-icon | ||
validation-message="Please select an option." | ||
> | ||
<calcite-label layout="inline" scale="m"> | ||
<calcite-radio-button value="one" scale="m"></calcite-radio-button> | ||
One | ||
</calcite-label> | ||
<calcite-label layout="inline" scale="m"> | ||
<calcite-radio-button value="two" scale="m"></calcite-radio-button> | ||
Two | ||
</calcite-label> | ||
<calcite-label layout="inline" scale="m"> | ||
<calcite-radio-button value="three" scale="m"></calcite-radio-button> | ||
Three | ||
</calcite-label> | ||
</calcite-radio-button-group> | ||
|
||
<calcite-radio-button-group | ||
layout="horizontal" | ||
name="validation" | ||
required | ||
scale="l" | ||
status="invalid" | ||
validation-icon | ||
validation-message="Please select an option." | ||
> | ||
<calcite-label layout="inline" scale="l"> | ||
<calcite-radio-button value="one" scale="l"></calcite-radio-button> | ||
One | ||
</calcite-label> | ||
<calcite-label layout="inline" scale="l"> | ||
<calcite-radio-button value="two" scale="l"></calcite-radio-button> | ||
Two | ||
</calcite-label> | ||
<calcite-label layout="inline" scale="l"> | ||
<calcite-radio-button value="three" scale="l"></calcite-radio-button> | ||
Three | ||
</calcite-label> | ||
</calcite-radio-button-group> | ||
</div> | ||
`; |
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
3 changes: 3 additions & 0 deletions
3
packages/calcite-components/src/components/radio-button-group/resources.ts
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const CSS = { | ||
itemWrapper: "item-wrapper", | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/calcite-components/src/components/segmented-control/resources.ts
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const CSS = { | ||
itemWrapper: "item-wrapper", | ||
}; |
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
19 changes: 13 additions & 6 deletions
19
packages/calcite-components/src/components/segmented-control/segmented-control.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,33 +1,40 @@ | ||
:host { | ||
@apply flex flex-col; | ||
} | ||
|
||
.item-wrapper { | ||
@apply bg-foreground-1 flex; | ||
inline-size: fit-content; | ||
outline: 1px solid var(--calcite-color-border-input); | ||
outline-offset: -1px; | ||
} | ||
|
||
:host([appearance="outline"]) { | ||
:host([appearance="outline"]) > .item-wrapper { | ||
@apply bg-transparent; | ||
} | ||
|
||
@include disabled(); | ||
|
||
:host([layout="vertical"]) { | ||
:host([layout="vertical"]) > .item-wrapper { | ||
@apply flex-col items-start self-start; | ||
} | ||
|
||
// segmented control width for full | ||
|
||
:host([width="full"]) { | ||
:host([width="full"]) > .item-wrapper { | ||
@apply w-full; | ||
min-inline-size: fit-content; | ||
|
||
::slotted(calcite-segmented-control-item) { | ||
@apply flex-auto; | ||
} | ||
} | ||
|
||
:host([width="full"][layout="vertical"]) ::slotted(calcite-segmented-control-item) { | ||
@apply justify-start; | ||
:host([width="full"][layout="vertical"]) > .item-wrapper { | ||
::slotted(calcite-segmented-control-item) { | ||
@apply justify-start; | ||
} | ||
} | ||
|
||
@include form-validation-message(); | ||
@include hidden-form-input(); | ||
@include base-component(); |
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.
Uh oh!
There was an error while loading. Please reload this page.