Skip to content

Commit 9de499e

Browse files
committed
Added control button group
1 parent e1e74a6 commit 9de499e

8 files changed

+70
-2
lines changed

src/app/CardGroupElement.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ export class CardGroupElement extends LitElement {
2222
:host {
2323
flex: 0 1 auto;
2424
}
25-
div.card-group {
25+
div {
2626
display: flex;
2727
flex-wrap: wrap;
2828
}
2929
3030
/* Colours */
3131
::slotted(wc-card) {
32+
position: relative;
3233
border: 1px solid var(--grey-20-color);
3334
border-radius: var(--card-border-radius);
3435
margin: var(--card-margin-y) var(--card-margin-x);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { LitElement, html, css, nothing } from 'lit';
2+
3+
/**
4+
* @class ControlButtonGroupElement
5+
*
6+
* This class is used as a group of control buttons, as decoration of a card, located on the
7+
* top right corner of the card.
8+
*
9+
* @example
10+
* <wc-control-button-group name="controls"></wc-control-button-group>
11+
*/
12+
export class ControlButtonGroupElement extends LitElement {
13+
static get localName() {
14+
return 'wc-control-button-group';
15+
}
16+
17+
static get styles() {
18+
return css`
19+
div {
20+
position: absolute;
21+
top: 0;
22+
right: 0;
23+
padding: 0;
24+
border: 0;
25+
background: transparent;
26+
}
27+
`;
28+
}
29+
30+
// eslint-disable-next-line class-methods-use-this
31+
get classes() {
32+
const classes = [];
33+
classes.push('control-button-group');
34+
return classes;
35+
}
36+
37+
render() {
38+
return html`
39+
<div class=${this.classes.join(' ') || nothing}>
40+
<button class="control-button" title="Close">CLOSE</button>
41+
<button class="control-button" title="Help">HELP</button>
42+
<slot></slot>
43+
</div>
44+
`;
45+
}
46+
}

src/button/button.css

Whitespace-only changes.

src/button/button.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// CSS
2+
import './button.css';
3+
4+
// Classes
5+
import { ControlButtonGroupElement } from './ControlButtonGroupElement';
6+
7+
// wc-control-button-group
8+
customElements.define(ControlButtonGroupElement.localName, ControlButtonGroupElement);

src/form/FormControlElement.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,18 @@ export class FormControlElement extends LitElement {
7979
8080
label.select {
8181
cursor: inherit;
82-
82+
8383
& select {
8484
width: 100%;
8585
cursor: pointer;
8686
font-family: inherit;
8787
appearance: none;
8888
padding: var(--form-select-padding-y) var(--form-select-padding-x);
89+
background-image: var(--form-select-background-image);
8990
background-color: var(--form-select-background-color);
91+
background-repeat: no-repeat;
92+
background-position: right center;
93+
background-size: contain;
9094
border: 1px solid var(--form-select-border-color);
9195
border-radius: var(--form-select-border-radius);
9296

src/form/form.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
--form-select-padding-y: 0.1em;
1818
--form-select-border-color: var(--control-color);
1919
--form-select-background-color: var(--control-color);
20+
--form-select-background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='currentColor'><path fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/></svg>");
2021
}

src/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ <h4>Card</h4>
102102
</script>
103103
</wc-card>
104104
<wc-card>
105+
<wc-control-button-group name="controls"></wc-control-button-group>
105106
<h1>Header</h1>
106107
<h2>Subtitle</h2>
107108
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
@@ -113,6 +114,12 @@ <h2>Subtitle</h2>
113114
<wc-card backgroundColor="success" width="12">
114115
<wc-icon name="check-circle-fill"></wc-icon> The operation was successful
115116
</wc-card>
117+
<wc-card backgroundColor="warning" width="6">
118+
<wc-icon name="exclamation-circle-fill"></wc-icon> Warning: Something happened
119+
</wc-card>
120+
<wc-card backgroundColor="error" width="6">
121+
<wc-icon name="x-circle-fill"></wc-icon> Error: An internal error occurred
122+
</wc-card>
116123
</wc-card-group>
117124
</wc-canvas-section>
118125
<wc-canvas-navbar id="end">END</wc-canvas-navbar>

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import './document.css';
88
import './app/app';
99
import './layout/layout';
1010
import './form/form';
11+
import './button/button';
1112

1213
// Other
1314
import './esbuild';

0 commit comments

Comments
 (0)