Skip to content
Merged
Show file tree
Hide file tree
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 Sep 29, 2022
caaaf15
fix(button): basebutton import
bennypowers Sep 29, 2022
9345b63
fix(button): stub necessary methods
bennypowers Sep 29, 2022
4747746
feat(button): form-associated custom element
bennypowers Oct 3, 2022
4058033
refactor(button): remove BaseButton reference
bennypowers Oct 3, 2022
2c8202c
docs: add if-defined to directives
bennypowers Oct 3, 2022
e9026f4
chore: update deps
bennypowers Oct 3, 2022
cd2f793
chore(button): remove ts-expect-error
bennypowers Oct 3, 2022
993244c
chore: depend on typescript directly
bennypowers Oct 3, 2022
297ca47
fix(button): move FACE helpers to lib, disabled
bennypowers Oct 4, 2022
d66bd47
Merge branch 'main' into feat/button
bennypowers Oct 6, 2022
ef33429
docs(button): fix demo
bennypowers Oct 6, 2022
1fa06b4
fix(button): fix FACE disabled behaviour
bennypowers Oct 6, 2022
6a35f30
chore: use upstream FACE from pfe-button
bennypowers Nov 30, 2022
2dafb8d
fix(button): import specifier
bennypowers Nov 30, 2022
9afeadd
fix(context): makes `on` default to shadow-private
bennypowers Dec 15, 2022
4957f85
docs: update changeset
bennypowers Dec 15, 2022
e7f85d2
Merge branch 'main' into feat/button
bennypowers Dec 21, 2022
21a7c9b
docs: remove instances of pfe-button
bennypowers Dec 21, 2022
dbeea73
chore: update package-lock
bennypowers Dec 21, 2022
14aacb0
Merge remote-tracking branch 'origin/main' into feat/button
bennypowers Dec 21, 2022
a929c5d
docs(button): add changeset and readme
bennypowers Dec 21, 2022
0f89fb1
docs(button): update docs and demos
bennypowers Dec 21, 2022
da6c09d
feat(button): add context, refactor
bennypowers Dec 21, 2022
d9842cd
fix(button): css fixes
bennypowers Dec 22, 2022
7fb9845
Merge branch 'main' into feat/button
bennypowers Dec 22, 2022
08d9e2d
fix: core review
bennypowers Dec 22, 2022
847faf5
chore: update .changeset/feat-rh-button.md
bennypowers Dec 22, 2022
718907a
fix: add play tokens excluding background opacity
bennypowers Dec 22, 2022
52597cc
fix(button): play background transparency
bennypowers Jan 22, 2023
ba91aa8
fix(button): focus states
bennypowers Jan 22, 2023
4ca15bc
Merge branch 'main' into feat/button
bennypowers Feb 5, 2023
bd1537f
fix(button): update styles
bennypowers Feb 5, 2023
a93b2cb
chore: use modern color syntax
bennypowers Feb 5, 2023
f588d5e
Merge branch 'main' into feat/button
bennypowers Feb 13, 2023
5ab2195
fix: fix merge commit
bennypowers Feb 13, 2023
853cacd
docs(button): separate demos
bennypowers Feb 13, 2023
068932a
docs(dialog): clean up demo js
bennypowers Feb 13, 2023
5308e64
fix(context-provider): notify context for imperatively added children
bennypowers Feb 14, 2023
fb3a859
fix(context): convert palette to theme when updating
bennypowers Feb 14, 2023
016e651
fix(button): pr review comments
bennypowers Feb 14, 2023
c2d5cbb
docs(button): nicer demos
bennypowers Feb 14, 2023
a79f4bb
chore: wtr config exclude _site
bennypowers Feb 14, 2023
7d54a97
docs: slight improvement to importMap
bennypowers Feb 14, 2023
f6c94c8
Merge branch 'main' into feat/button
bennypowers Feb 14, 2023
9e57377
chore: reset package-lock to main
bennypowers Feb 14, 2023
84c562e
refactor(button): use icon color tokens
bennypowers Feb 14, 2023
ad4d28d
Merge branch 'main' into feat/button
bennypowers Feb 15, 2023
9593006
fix(button): secondary colors
bennypowers Feb 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/feat-rh-button.md
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>
```
4 changes: 4 additions & 0 deletions .changeset/rh-context-slotchange.md
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.
4 changes: 4 additions & 0 deletions .changeset/rh-context-theme.md
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
2 changes: 1 addition & 1 deletion .stylelintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ignoreFiles:
rules:
alpha-value-notation: number # TODO: fix for `percentage` in tokens
color-hex-length: long
color-function-notation: legacy # TODO: fix for `modern` in tokens
color-function-notation: modern
custom-property-pattern: _?[a-z]+[a-z0-9-]*
declaration-block-no-redundant-longhand-properties:
- true
Expand Down
6 changes: 1 addition & 5 deletions docs/_plugins/importMap.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,16 @@ module.exports = function(eleventyConfig, {
Object.assign(json.imports ?? {}, Object.values(json.scopes ?? {}).find(x => 'lit-html' in x));
// ENDHACK

// HACK: no clue why we need to do this
// TODO: automate this
Object.assign(json.imports ?? {}, {
// TODO
// '@rhds/elements/lib/': '/assets/packages/@rhds/elements/lib/',
// '@rhds/elements/lib/context/': '/assets/packages/@rhds/elements/lib/context/',
// '@rhds/elements/lib/context/color/': '/assets/packages/@rhds/elements/lib/context/color/',
// '@rhds/elements/lib/context/color/consumer.js': '/assets/packages/@rhds/elements/lib/context/color/consumer.js',
'@rhds/elements/lib/': '/assets/lib/',
'@rhds/elements/lib/context/': '/assets/lib/context/',
'@rhds/elements/lib/context/color/': '/assets/lib/context/color/',
'@rhds/elements/lib/context/color/consumer.js': '/assets/lib/context/color/consumer.js',
});
// ENDHACk

performance.mark('importMap-end');

Expand Down Expand Up @@ -122,4 +119,3 @@ function logPerf() {
}
/* eslint-enable no-console */
}

26 changes: 26 additions & 0 deletions elements/rh-button/README.md
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>
```
22 changes: 22 additions & 0 deletions elements/rh-button/demo/color-context.html
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>
3 changes: 3 additions & 0 deletions elements/rh-button/demo/color-context.js
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));
}
52 changes: 52 additions & 0 deletions elements/rh-button/demo/demo.css
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;
}
31 changes: 31 additions & 0 deletions elements/rh-button/demo/form-control.html
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>&lt;fieldset&gt;</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>
28 changes: 28 additions & 0 deletions elements/rh-button/demo/form-control.js
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);
15 changes: 15 additions & 0 deletions elements/rh-button/demo/rh-button.html
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>
5 changes: 5 additions & 0 deletions elements/rh-button/demo/rh-button.js
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);
17 changes: 17 additions & 0 deletions elements/rh-button/docs/rh-button.md
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 %}
Loading