-
Notifications
You must be signed in to change notification settings - Fork 106
feat(checkbox): add pf-checkbox #2608
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
Draft
bennypowers
wants to merge
8
commits into
main
Choose a base branch
from
feat/pf-checkbox
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
82f0e7d
feat(checkbox): add pf-checkbox
bennypowers 0328c9f
docs: changeset
bennypowers c2cd390
fix(checkbox): disabled state on nested controls
bennypowers a0226ab
docs: basic docs
bennypowers 081eb3b
Merge branch 'main' into feat/pf-checkbox
bennypowers a22895e
fix(checkbox): review notes
bennypowers 1c71380
Merge branch 'main' into feat/pf-checkbox
bennypowers 3634aad
docs: update elements/pf-checkbox/pf-checkbox.ts
bennypowers 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| "@patternfly/elements": minor | ||
| --- | ||
| ✨ Added `<pf-checkbox>` | ||
|
|
||
| ```html | ||
| <form> | ||
| <pf-checkbox label="Parent" | ||
| name="options" | ||
| value="parent"> | ||
| <pf-checkbox label="Child 1" | ||
| name="options" | ||
| value="child1"></pf-checkbox> | ||
| <pf-checkbox label="Child 2" | ||
| name="options" | ||
| value="child2"></pf-checkbox> | ||
| </pf-checkbox> | ||
| <pf-checkbox label="Sibling" | ||
| name="options" | ||
| value="sibling"></pf-checkbox> | ||
| <pf-button>Submit</pf-button> | ||
| </form> | ||
| ``` |
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Checkbox | ||
| A **checkbox** is used to select a single item or multiple items, typically to choose elements to perform an action or to reflect a binary setting. | ||
|
|
||
| ```html | ||
| <pf-checkbox label="Checkbox"></pf-checkbox> | ||
| ``` |
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,13 @@ | ||
| <pf-checkbox label="Parent"> | ||
| <pf-checkbox label="Child 1"></pf-checkbox> | ||
| <pf-checkbox label="Child 2"></pf-checkbox> | ||
| <pf-text-input label="Text"></pf-text-input> | ||
| </pf-checkbox> | ||
| <pf-checkbox label="Sibling"></pf-checkbox> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| import '@patternfly/elements/pf-text-input/pf-text-input.js'; | ||
| </script> | ||
|
|
||
|
|
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,7 @@ | ||
| <pf-checkbox disabled label="Disabled"></pf-checkbox> | ||
| <pf-checkbox disabled checked label="Disabled and checked"></pf-checkbox> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| </script> | ||
|
|
||
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,41 @@ | ||
|
|
||
| <form id="face"> | ||
| <pf-checkbox label="Parent" | ||
| name="options" | ||
| value="parent"> | ||
| <pf-checkbox label="Child 1" | ||
| name="options" | ||
| value="child1"></pf-checkbox> | ||
| <pf-checkbox label="Child 2" | ||
| name="options" | ||
| value="child2"></pf-checkbox> | ||
| </pf-checkbox> | ||
| <pf-checkbox label="Sibling" | ||
| name="options" | ||
| value="sibling"></pf-checkbox> | ||
| <pf-button>Submit and Log Results</pf-button> | ||
| <fieldset> | ||
| <legend>FormData</legend> | ||
| <output name="output"></output> | ||
| </fieldset> | ||
| </form> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| const form = document.getElementById('face') | ||
| form.addEventListener('submit', event => { | ||
| event.preventDefault(); | ||
| const formdata = new FormData(form); | ||
| console.log(event); | ||
| console.log(formdata) | ||
| const fields = Array.from(formdata.entries()).reduce((acc, [key, val]) => ({ ...acc, | ||
| [key]: key in acc ? [acc[key], val].flat() : val | ||
| }), {}); | ||
|
|
||
| delete fields.output; | ||
|
|
||
| form.elements.output.textContent = JSON.stringify(fields); | ||
| }) | ||
| </script> | ||
|
|
||
|
|
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,12 @@ | ||
| <label><pf-checkbox></pf-checkbox> Wrapped</label> | ||
|
|
||
| <label for="using-for">Using <code>for</code></label> | ||
| <pf-checkbox id="using-for"></pf-checkbox> | ||
|
|
||
| <pf-checkbox label="Using label attribute"></pf-checkbox> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| </script> | ||
|
|
||
|
|
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,11 @@ | ||
| <pf-checkbox label="Parent"> | ||
| <pf-checkbox label="Child 1"></pf-checkbox> | ||
| <pf-checkbox label="Child 2"></pf-checkbox> | ||
| </pf-checkbox> | ||
| <pf-checkbox label="Sibling"></pf-checkbox> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| </script> | ||
|
|
||
|
|
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,6 @@ | ||
| <pf-checkbox></pf-checkbox> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| </script> | ||
|
|
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,10 @@ | ||
| <pf-checkbox label="Required" required></pf-checkbox> | ||
brianferry marked this conversation as resolved.
Show resolved
Hide resolved
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. Showing as valid for me when I uncheck it. |
||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| const x = document.querySelector('pf-checkbox') | ||
| await x.updateComplete; | ||
| x.checkValidity(); | ||
| </script> | ||
|
|
||
|
|
||
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,9 @@ | ||
| <pf-checkbox label="With body"> | ||
| <span slot="body">This is where custom content goes</span> | ||
| </pf-checkbox> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| </script> | ||
|
|
||
|
|
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,11 @@ | ||
| <pf-checkbox label="With description and body"> | ||
| <span slot="body">This is where custom content goes</span> | ||
| <span slot="description">Single-tenant cloud service hosted and managed by Red Hat that offers high-availability enterprise-grade clusters in a virtual private cloud on AWS or GCP.</span> | ||
| </pf-checkbox> | ||
|
|
||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| </script> | ||
|
|
||
|
|
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,9 @@ | ||
| <pf-checkbox label="With description"> | ||
| <span slot="description">Single-tenant cloud service hosted and managed by Red Hat that offers high-availability enterprise-grade clusters in a virtual private cloud on AWS or GCP.</span> | ||
| </pf-checkbox> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-checkbox/pf-checkbox.js'; | ||
| </script> | ||
|
|
||
|
|
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,17 @@ | ||
| {% renderOverview %} | ||
| <pf-checkbox label="Checkbox"></pf-checkbox> | ||
| {% endrenderOverview %} | ||
|
|
||
| {% band header="Usage" %}{% endband %} | ||
|
|
||
| {% renderSlots %}{% endrenderSlots %} | ||
|
|
||
| {% renderAttributes %}{% endrenderAttributes %} | ||
|
|
||
| {% renderMethods %}{% endrenderMethods %} | ||
|
|
||
| {% renderEvents %}{% endrenderEvents %} | ||
|
|
||
| {% renderCssCustomProperties %}{% endrenderCssCustomProperties %} | ||
|
|
||
| {% renderCssParts %}{% endrenderCssParts %} |
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,64 @@ | ||
| :host { | ||
| --pf-c-check--GridGap: var(--pf-global--spacer--xs, 0.25rem) var(--pf-global--spacer--sm, 0.5rem); | ||
| --pf-c-check__label--disabled--Color: var(--pf-global--disabled-color--100, #6a6e73); | ||
| --pf-c-check__label--Color: var(--pf-global--Color--100, #151515); | ||
| --pf-c-check__label--FontWeight: var(--pf-global--FontWeight--normal, 400); | ||
| --pf-c-check__label--FontSize: var(--pf-global--FontSize--md, 1rem); | ||
| --pf-c-check__label--LineHeight: var(--pf-global--LineHeight--sm, 1.3); | ||
| --pf-c-check__input--Height: var(--pf-c-check__label--FontSize); | ||
| --pf-c-check__input--MarginTop: calc(((var(--pf-c-check__label--FontSize) * var(--pf-c-check__label--LineHeight)) - var(--pf-c-check__input--Height)) / 2); | ||
| --pf-c-check__description--FontSize: var(--pf-global--FontSize--sm, 0.875rem); | ||
| --pf-c-check__description--Color: var(--pf-global--Color--200, #6a6e73); | ||
| --pf-c-check__body--MarginTop: var(--pf-global--spacer--sm, 0.5rem); | ||
| --pf-c-check__label-required--MarginLeft: var(--pf-global--spacer--xs, 0.25rem); | ||
| --pf-c-check__label-required--FontSize: var(--pf-global--FontSize--sm, 0.875rem); | ||
| --pf-c-check__label-required--Color: var(--pf-global--danger-color--100, #c9190b); | ||
| display: grid; | ||
| grid-template-columns: auto 1fr; | ||
| grid-gap: var(--pf-c-check--GridGap); | ||
| align-items: start; | ||
| justify-items: start; | ||
| } | ||
|
|
||
| [hidden] { display: none !important; } | ||
|
|
||
| #nested::slotted(*) { | ||
| margin-inline-start: var(--pf-global--spacer--md, 1rem); | ||
| grid-column: -1/1; | ||
| } | ||
|
|
||
| #description { | ||
| display: inline; | ||
| grid-column: 2; | ||
| font-size: var(--pf-c-check__description--FontSize); | ||
| color: var(--pf-c-check__description--Color); | ||
| } | ||
|
|
||
| #body { | ||
| display: inline; | ||
| grid-column: 2; | ||
| margin-top: var(--pf-c-check__body--MarginTop); | ||
| } | ||
|
|
||
| input { | ||
| height: var(--pf-c-check__input--Height); | ||
| margin-block-start: var(--pf-c-check__input--MarginTop); | ||
| } | ||
|
|
||
| label { | ||
| font-size: var(--pf-c-check__label--FontSize); | ||
| font-weight: var(--pf-c-check__label--FontWeight); | ||
| line-height: var(--pf-c-check__label--LineHeight); | ||
| color: var(--pf-c-check__label--Color); | ||
| } | ||
|
|
||
| label.disabled { | ||
| color: var(--pf-c-check__label--disabled--Color); | ||
| } | ||
|
|
||
|
|
||
| #required { | ||
| margin-left: var(--pf-c-check__label-required--MarginLeft); | ||
| font-size: var(--pf-c-check__label-required--FontSize); | ||
| color: var(--pf-c-check__label-required--Color); | ||
| } |
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.