-
Notifications
You must be signed in to change notification settings - Fork 34
feat(button): add <rh-button> #550
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 all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
ac699cf
feat(button): initial commit
bennypowers caaaf15
fix(button): basebutton import
bennypowers 9345b63
fix(button): stub necessary methods
bennypowers 4747746
feat(button): form-associated custom element
bennypowers 4058033
refactor(button): remove BaseButton reference
bennypowers 2c8202c
docs: add if-defined to directives
bennypowers e9026f4
chore: update deps
bennypowers cd2f793
chore(button): remove ts-expect-error
bennypowers 993244c
chore: depend on typescript directly
bennypowers 297ca47
fix(button): move FACE helpers to lib, disabled
bennypowers d66bd47
Merge branch 'main' into feat/button
bennypowers ef33429
docs(button): fix demo
bennypowers 1fa06b4
fix(button): fix FACE disabled behaviour
bennypowers 6a35f30
chore: use upstream FACE from pfe-button
bennypowers 2dafb8d
fix(button): import specifier
bennypowers 9afeadd
fix(context): makes `on` default to shadow-private
bennypowers 4957f85
docs: update changeset
bennypowers e7f85d2
Merge branch 'main' into feat/button
bennypowers 21a7c9b
docs: remove instances of pfe-button
bennypowers dbeea73
chore: update package-lock
bennypowers 14aacb0
Merge remote-tracking branch 'origin/main' into feat/button
bennypowers a929c5d
docs(button): add changeset and readme
bennypowers 0f89fb1
docs(button): update docs and demos
bennypowers da6c09d
feat(button): add context, refactor
bennypowers d9842cd
fix(button): css fixes
bennypowers 7fb9845
Merge branch 'main' into feat/button
bennypowers 08d9e2d
fix: core review
bennypowers 847faf5
chore: update .changeset/feat-rh-button.md
bennypowers 718907a
fix: add play tokens excluding background opacity
bennypowers 52597cc
fix(button): play background transparency
bennypowers ba91aa8
fix(button): focus states
bennypowers 4ca15bc
Merge branch 'main' into feat/button
bennypowers bd1537f
fix(button): update styles
bennypowers a93b2cb
chore: use modern color syntax
bennypowers f588d5e
Merge branch 'main' into feat/button
bennypowers 5ab2195
fix: fix merge commit
bennypowers 853cacd
docs(button): separate demos
bennypowers 068932a
docs(dialog): clean up demo js
bennypowers 5308e64
fix(context-provider): notify context for imperatively added children
bennypowers fb3a859
fix(context): convert palette to theme when updating
bennypowers 016e651
fix(button): pr review comments
bennypowers c2d5cbb
docs(button): nicer demos
bennypowers a79f4bb
chore: wtr config exclude _site
bennypowers 7d54a97
docs: slight improvement to importMap
bennypowers f6c94c8
Merge branch 'main' into feat/button
bennypowers 9e57377
chore: reset package-lock to main
bennypowers 84c562e
refactor(button): use icon color tokens
bennypowers ad4d28d
Merge branch 'main' into feat/button
bennypowers 9593006
fix(button): secondary colors
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,13 @@ | ||
| --- | ||
| "@rhds/elements": minor | ||
| --- | ||
|
|
||
| ✨ Added `<rh-button>`. | ||
|
|
||
| Button is a form-associated custom element. Buttons allow users to | ||
| perform an action when triggered. They feature a text label, a background or a | ||
| border, and icons. | ||
|
|
||
| ```html | ||
| <rh-button>Submit</rh-button> | ||
| ``` |
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,4 @@ | ||
| --- | ||
| "@rhds/elements": patch | ||
| --- | ||
| `<rh-context-provider>`: notify children of context when adding them using javascript. |
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,4 @@ | ||
| --- | ||
| "@rhds/elements": patch | ||
| --- | ||
| `<rh-context-provider>`: set color context, rather than palette, on consumers |
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
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,26 @@ | ||
| # Button | ||
|
|
||
| Buttons allow users to perform an action when triggered. They feature a text | ||
| label, a background or a border, and icons. | ||
|
|
||
| ## Installation | ||
|
|
||
| If using npm/bundlers: | ||
|
|
||
| ```bash | ||
| npm install @rhds/elements | ||
| ``` | ||
|
|
||
| Then once installed, import it to your application: | ||
|
|
||
| ```js | ||
| import '@rhds/elements/rh-button/rh-button.js'; | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic Button | ||
|
|
||
| ```html | ||
| <rh-button>Ok</rh-button> | ||
| ``` |
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,22 @@ | ||
| <link rel="stylesheet" href="demo.css"> | ||
| <script type="module" src="rh-button.js"></script> | ||
| <script type="module" src="color-context.js"></script> | ||
|
|
||
| <template id="template"> | ||
| <rh-button danger>Danger</rh-button> | ||
| <rh-button>Primary</rh-button> | ||
| <rh-button variant="link">Link</rh-button> | ||
| <rh-button variant="secondary">Secondary</rh-button> | ||
| <rh-button variant="secondary" danger>Secondary Danger</rh-button> | ||
| <rh-button variant="tertiary">Tertiary</rh-button> | ||
| <rh-button variant="close">Close</rh-button> | ||
| <rh-button variant="play">Play</rh-button> | ||
| <rh-button disabled>Disabled</rh-button> | ||
| </template> | ||
|
|
||
| <rh-context-provider color-palette="lightest"></rh-context-provider> | ||
| <rh-context-provider color-palette="lighter"></rh-context-provider> | ||
| <rh-context-provider color-palette="light"></rh-context-provider> | ||
| <rh-context-provider color-palette="dark"></rh-context-provider> | ||
| <rh-context-provider color-palette="darker"></rh-context-provider> | ||
| <rh-context-provider color-palette="darkest"></rh-context-provider> |
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 @@ | ||
| for (const provider of document.querySelectorAll('rh-context-provider')) { | ||
| provider.append(document.getElementById('template').content.cloneNode(true)); | ||
| } |
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,52 @@ | ||
| section { | ||
| display: flex; | ||
| align-items: center; | ||
| flex-flow: row wrap; | ||
| gap: var(--rh-space-sm, 6px); | ||
| padding: var(--rh-space-xl, 24px) var(--rh-space-4xl, 64px); | ||
| } | ||
|
|
||
| rh-context-provider { | ||
| padding-block: var(--rh-space-lg, 16px); | ||
| padding-inline: var(--rh-space-6xl, 96px); | ||
| display: flex; | ||
| align-items: center; | ||
| gap: var(--rh-space-sm, 6px); | ||
| } | ||
|
|
||
| h2 { | ||
| width: 100%; | ||
| } | ||
|
|
||
| #checkboxes { | ||
| display: grid; | ||
| grid-template-columns: min-content 1fr; | ||
| } | ||
|
|
||
| label { | ||
| display: block; | ||
| } | ||
|
|
||
| form h2 { | ||
| width: 100%; | ||
| } | ||
|
|
||
| form output { | ||
| text-transform: capitalize; | ||
| } | ||
|
|
||
| datalist { | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: space-between; | ||
| writing-mode: vertical-lr; | ||
| } | ||
|
|
||
| datalist, | ||
| input { | ||
| width: 200px; | ||
| } | ||
|
|
||
| option { | ||
| padding: 0; | ||
| } |
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,31 @@ | ||
| <link rel="stylesheet" href="demo.css"> | ||
| <script type="module" src="rh-button.js"></script> | ||
| <script type="module" src="form-control.js"></script> | ||
|
|
||
| <section> | ||
| <h2>Form Control</h2> | ||
| <form id="form"> | ||
| <fieldset id="fieldset"> | ||
| <legend> | ||
| rh-button in a <code><fieldset></code> element; | ||
| clicking this button must submit the form | ||
| </legend> | ||
| <rh-button id="button" type="submit">Submit</rh-button> | ||
| </fieldset> | ||
|
|
||
| <fieldset id="checkboxes"> | ||
| <legend>Use these checkboxes to toggle disabled state</legend> | ||
| <input id="fst" type="checkbox" data-controls="fieldset" type="checkbox"> | ||
| <label for="fst">Disable fieldset</label> | ||
| <input id="btn" type="checkbox" data-controls="button"> | ||
| <label for="btn">Disable rh-button</label> | ||
| </fieldset> | ||
|
|
||
| <fieldset id="outputs"> | ||
| <legend>Observe and reset form state</legend> | ||
| <rh-button type="reset">Reset</rh-button> | ||
| <label for="output">Form status:</label> | ||
| <output id="output">Pending</output> | ||
| </fieldset> | ||
| </form> | ||
| </section> |
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,28 @@ | ||
| const form = document.getElementById('form'); | ||
| const fieldset = document.getElementById('fieldset'); | ||
|
|
||
| /** @this {HTMLFormElement} */ | ||
| function onSubmit(event) { | ||
| event.preventDefault(); | ||
| this.elements.output.textContent = 'Submitted'; | ||
| } | ||
|
|
||
| /** @this {HTMLFormElement} */ | ||
| function onReset() { | ||
| fieldset.disabled = false; | ||
| this.elements.output.textContent = 'Pending'; | ||
| } | ||
|
|
||
| /** @this{HTMLInputElement} */ | ||
| function onChange({ target: { checked, dataset: { controls } } }) { | ||
| // eslint-disable-next-line no-console | ||
| console.log(`${controls}.disabled =`, checked); | ||
| const el = document.getElementById(controls); | ||
| if (el) { | ||
| el.disabled = checked; | ||
| } | ||
| } | ||
|
|
||
| form.addEventListener('submit', onSubmit); | ||
| form.addEventListener('reset', onReset); | ||
| form.addEventListener('change', onChange); |
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,15 @@ | ||
| <link rel="stylesheet" href="demo.css"> | ||
| <script type="module" src="rh-button.js"></script> | ||
|
|
||
| <section> | ||
| <h2>Variants</h2> | ||
| <rh-button danger>Danger</rh-button> | ||
| <rh-button>Primary</rh-button> | ||
| <rh-button variant="link">Link</rh-button> | ||
| <rh-button variant="secondary">Secondary</rh-button> | ||
| <rh-button variant="secondary" danger>Secondary Danger</rh-button> | ||
| <rh-button variant="tertiary">Tertiary</rh-button> | ||
| <rh-button variant="close">Close</rh-button> | ||
| <rh-button variant="play">Play</rh-button> | ||
| <rh-button disabled>Disabled</rh-button> | ||
| </section> | ||
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,5 @@ | ||
| import '@rhds/elements/rh-context-provider/rh-context-provider.js'; | ||
| import '@rhds/elements/rh-button/rh-button.js'; | ||
|
|
||
| import { Logger } from '@patternfly/pfe-core/controllers/logger.js'; | ||
| Logger.debugLog(true); |
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 %} | ||
| <rh-button>Ok</rh-button> | ||
| {% endrenderOverview %} | ||
|
|
||
| {% band header="Usage" %}{% endband %} | ||
|
|
||
| {% renderSlots %}{% endrenderSlots %} | ||
|
|
||
| {% renderAttributes %}{% endrenderAttributes %} | ||
|
|
||
| {% renderMethods %}{% endrenderMethods %} | ||
|
|
||
| {% renderEvents %}{% endrenderEvents %} | ||
|
|
||
| {% renderCssCustomProperties %}{% endrenderCssCustomProperties %} | ||
|
|
||
| {% renderCssParts %}{% endrenderCssParts %} |
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.