@redvars/peacock 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/avatar.css.js +3 -3
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/avatar.css.js.map +1 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/avatar.d.ts +16 -3
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/avatar.js +16 -3
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/avatar.js.map +1 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/p-avatar.d.ts +3 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/p-avatar.js +10 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/p-avatar.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.css.d.ts +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.css.js +34 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.css.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.d.ts +23 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.js +54 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/index.d.ts +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/index.js +2 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/index.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/p-badge.d.ts +3 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/p-badge.js +10 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/p-badge.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.css.d.ts +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.css.js +12 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.css.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.d.ts +27 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.js +58 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/index.d.ts +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/index.js +2 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/index.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.css.d.ts +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.css.js +58 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.css.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.d.ts +28 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.js +68 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/index.d.ts +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/index.js +2 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/index.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/icon.d.ts +15 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/icon.js +10 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/icon.js.map +1 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/p-icon.d.ts +1 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/p-icon.js +4 -4
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/p-icon.js.map +1 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/index.d.ts +5 -2
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/index.js +5 -2
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/index.js.map +1 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/link/index.d.ts +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/link/index.js +2 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/link/index.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/link/link.css.d.ts +2 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/link/link.css.js +36 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/link/link.css.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/link/link.d.ts +12 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/link/link.js +18 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/link/link.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/peacock-loader.js +41 -2
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/peacock-loader.js.map +1 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/styleMixins.css.d.ts +9 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/styleMixins.css.js +46 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/styleMixins.css.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/text/text.css.d.ts +2 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/text/text.css.js +70 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/text/text.css.js.map +1 -0
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/utils.d.ts +1 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/utils.js +32 -7
- package/.rollup.cache/E/git/redvars/peacock/components/dist/src/utils.js.map +1 -1
- package/.rollup.cache/E/git/redvars/peacock/components/dist/tsconfig.tsbuildinfo +1 -1
- package/bin/typedoc-gen.mjs +64 -0
- package/custom-elements-manifest.config.mjs +8 -21
- package/demo/index.html +21 -9
- package/demo/int.html +2 -0
- package/dist/assets/styles/tokens.css +8 -1
- package/dist/{component/avatar.js → avatar.js} +23 -13
- package/dist/avatar.js.map +1 -0
- package/dist/badge.js +89 -0
- package/dist/badge.js.map +1 -0
- package/dist/class-map-DpvLRi0h.js +11 -0
- package/dist/class-map-DpvLRi0h.js.map +1 -0
- package/dist/clock.js +70 -0
- package/dist/clock.js.map +1 -0
- package/dist/custom-elements-jsdocs.json +656 -0
- package/dist/directive-BKuZRRPO.js +9 -0
- package/dist/directive-BKuZRRPO.js.map +1 -0
- package/dist/divider.js +123 -0
- package/dist/divider.js.map +1 -0
- package/dist/{component/Icon.js → icon.js} +15 -9
- package/dist/icon.js.map +1 -0
- package/dist/index.js +11 -88
- package/dist/index.js.map +1 -1
- package/dist/peacock-loader.js +141 -3
- package/dist/peacock-loader.js.map +1 -1
- package/dist/property-D4Kn9TsY.js +63 -0
- package/dist/property-D4Kn9TsY.js.map +1 -0
- package/dist/src/avatar/avatar.d.ts +16 -3
- package/dist/src/avatar/p-avatar.d.ts +3 -0
- package/dist/src/badge/badge.css.d.ts +1 -0
- package/dist/src/badge/badge.d.ts +23 -0
- package/dist/src/badge/index.d.ts +1 -0
- package/dist/src/badge/p-badge.d.ts +3 -0
- package/dist/src/clock/clock.css.d.ts +1 -0
- package/dist/src/clock/clock.d.ts +27 -0
- package/dist/src/clock/index.d.ts +1 -0
- package/dist/src/divider/divider.css.d.ts +1 -0
- package/dist/src/divider/divider.d.ts +28 -0
- package/dist/src/divider/index.d.ts +1 -0
- package/dist/src/icon/icon.d.ts +15 -1
- package/dist/src/icon/p-icon.d.ts +1 -1
- package/dist/src/index.d.ts +5 -2
- package/dist/src/link/link.css.d.ts +2 -0
- package/dist/src/styleMixins.css.d.ts +9 -0
- package/dist/src/text/text.css.d.ts +2 -0
- package/dist/src/utils.d.ts +1 -1
- package/dist/state-CxzmLNIi.js +10 -0
- package/dist/state-CxzmLNIi.js.map +1 -0
- package/dist/styleMixins.css-CivfMYtB.js +17 -0
- package/dist/styleMixins.css-CivfMYtB.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{src/utils.js → utils-_5no4mk7.js} +37 -10
- package/dist/utils-_5no4mk7.js.map +1 -0
- package/package.json +17 -9
- package/readme.md +178 -0
- package/rollup.config.js +72 -34
- package/scratch.mjs +0 -0
- package/src/avatar/avatar.css.ts +3 -3
- package/src/avatar/avatar.ts +16 -3
- package/src/avatar/demo/index.html +2 -2
- package/src/avatar/p-avatar.ts +5 -0
- package/src/badge/badge.css.ts +34 -0
- package/src/badge/badge.ts +51 -0
- package/src/badge/demo/index.html +62 -0
- package/src/badge/index.ts +1 -0
- package/src/badge/p-badge.ts +5 -0
- package/src/clock/clock.css.ts +12 -0
- package/src/clock/clock.ts +57 -0
- package/src/clock/demo/index.html +26 -0
- package/src/clock/index.ts +1 -0
- package/src/divider/demo/index.html +58 -0
- package/src/divider/divider.css.ts +58 -0
- package/src/divider/divider.ts +65 -0
- package/src/divider/index.ts +1 -0
- package/src/icon/demo/index.html +4 -4
- package/src/icon/icon.ts +16 -2
- package/src/icon/p-icon.ts +1 -1
- package/src/index.ts +5 -2
- package/src/link/link.css.ts +36 -0
- package/src/peacock-loader.ts +49 -2
- package/src/styleMixins.css.ts +55 -0
- package/src/styles.d.ts +11 -0
- package/src/text/text.css.ts +76 -0
- package/src/utils.ts +42 -7
- package/tsconfig.json +1 -1
- package/README.md +0 -46
- package/custom-elements.md +0 -268
- package/demo/tokens.css +0 -510
- package/dist/component/Icon.js.map +0 -1
- package/dist/component/avatar.js.map +0 -1
- package/dist/icon-1wpxQtrZ.js +0 -341
- package/dist/icon-1wpxQtrZ.js.map +0 -1
- package/dist/src/LoaderUtils.js +0 -81
- package/dist/src/LoaderUtils.js.map +0 -1
- package/dist/src/avatar/avatar.css.js +0 -41
- package/dist/src/avatar/avatar.css.js.map +0 -1
- package/dist/src/avatar/avatar.js +0 -49
- package/dist/src/avatar/avatar.js.map +0 -1
- package/dist/src/avatar/index.js +0 -2
- package/dist/src/avatar/index.js.map +0 -1
- package/dist/src/icon/datasource.js +0 -20
- package/dist/src/icon/datasource.js.map +0 -1
- package/dist/src/icon/icon.css.js +0 -22
- package/dist/src/icon/icon.css.js.map +0 -1
- package/dist/src/icon/icon.js +0 -124
- package/dist/src/icon/icon.js.map +0 -1
- package/dist/src/icon/index.js +0 -2
- package/dist/src/icon/index.js.map +0 -1
- package/dist/src/icon/p-icon.js +0 -15
- package/dist/src/icon/p-icon.js.map +0 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +0 -1
- package/dist/src/peacock-loader.js +0 -16
- package/dist/src/peacock-loader.js.map +0 -1
- package/dist/src/utils.js.map +0 -1
- package/dist/test/icon.test.js +0 -14
- package/dist/test/icon.test.js.map +0 -1
- package/dist/utils-CSwoJIcG.js +0 -171
- package/dist/utils-CSwoJIcG.js.map +0 -1
- package/readme-gen.mjs +0 -11
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang='en-GB'>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset='utf-8'>
|
|
5
|
+
<meta name='viewport' content='width=device-width, initial-scale=1.0, viewport-fit=cover' />
|
|
6
|
+
<link rel='stylesheet' href='/dist/assets/styles/tokens.css' />
|
|
7
|
+
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
body {
|
|
11
|
+
background: #fafafa;
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
.container-horizontal {
|
|
20
|
+
display: inline-block;
|
|
21
|
+
margin-right: 1rem;
|
|
22
|
+
padding: 1rem;
|
|
23
|
+
width: 200px;
|
|
24
|
+
border: 1px solid var(--color-outline);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.container-vertical {
|
|
28
|
+
display: flex;
|
|
29
|
+
height: 150px;
|
|
30
|
+
margin-bottom: 1rem;
|
|
31
|
+
padding: 1rem;
|
|
32
|
+
width: 250px;
|
|
33
|
+
border: 1px solid var(--color-outline);
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<div class="container-horizontal">
|
|
40
|
+
<p>Content A</p>
|
|
41
|
+
<p-divider>or</p-divider>
|
|
42
|
+
<p>Content B</p>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<div class="container-vertical">
|
|
46
|
+
<p>Content A</p>
|
|
47
|
+
<p-divider vertical="true">or</p-divider>
|
|
48
|
+
<p>Content B</p>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
<script type='module'>
|
|
54
|
+
import { Divider } from '/dist/index.js';
|
|
55
|
+
window.customElements.define('p-divider', Divider);
|
|
56
|
+
</script>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export const styles = css`
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
|
|
7
|
+
--divider-color: var(--color-outline-variant);
|
|
8
|
+
--divider-padding: var(--spacing-200);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.divider {
|
|
12
|
+
display: flex;
|
|
13
|
+
margin: 0;
|
|
14
|
+
@include get-typography(body-small-emphasized);
|
|
15
|
+
color: var(--divider-color);
|
|
16
|
+
|
|
17
|
+
&:not(.vertical) {
|
|
18
|
+
width: 100%;
|
|
19
|
+
padding: var(--divider-padding) 0;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
|
|
23
|
+
.line {
|
|
24
|
+
width: 100%;
|
|
25
|
+
border-top: 1px solid var(--divider-color);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&.slot-has-content .slot-container {
|
|
29
|
+
padding: 0 var(--spacing-200);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.vertical {
|
|
34
|
+
height: 100%;
|
|
35
|
+
padding: 0 var(--divider-padding);
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
|
|
40
|
+
.line {
|
|
41
|
+
height: 100%;
|
|
42
|
+
border-right: 1px solid var(--divider-color);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&.slot-has-content .slot-container {
|
|
46
|
+
padding: var(--spacing-200) 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host(:not([vertical])) {
|
|
52
|
+
width: auto;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:host([vertical]) {
|
|
56
|
+
height: auto;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { html, LitElement } from 'lit';
|
|
2
|
+
import { property, state } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { styles } from './divider.css.js';
|
|
5
|
+
import { observerSlotChangesWithCallback } from '../utils.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @label Divider
|
|
9
|
+
* @tag p-divider
|
|
10
|
+
* @rawTag divider
|
|
11
|
+
*
|
|
12
|
+
* @summary The divider component is used to visually separate content.
|
|
13
|
+
* @overview
|
|
14
|
+
* - Dividers are used to separate content into clear groups, making it easier for users to scan and understand the information presented.
|
|
15
|
+
* - They can be oriented either vertically or horizontally, depending on the layout requirements.
|
|
16
|
+
*
|
|
17
|
+
* @cssprop --divider-color - Controls the color of the divider.
|
|
18
|
+
* @cssprop --divider-padding - Controls the padding of the divider.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```html
|
|
22
|
+
* <p-divider style="width: 12rem;">or</p-divider>
|
|
23
|
+
* ```
|
|
24
|
+
* @tags display
|
|
25
|
+
*/
|
|
26
|
+
export class Divider extends LitElement {
|
|
27
|
+
static styles = [styles];
|
|
28
|
+
|
|
29
|
+
@property({ type: Boolean, reflect: true }) vertical = false;
|
|
30
|
+
|
|
31
|
+
@state()
|
|
32
|
+
slotHasContent = false;
|
|
33
|
+
|
|
34
|
+
firstUpdated() {
|
|
35
|
+
observerSlotChangesWithCallback(
|
|
36
|
+
this.renderRoot.querySelector('slot'),
|
|
37
|
+
hasContent => {
|
|
38
|
+
this.slotHasContent = hasContent;
|
|
39
|
+
this.requestUpdate();
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
return html`<div
|
|
46
|
+
class=${classMap({
|
|
47
|
+
divider: true,
|
|
48
|
+
vertical: this.vertical,
|
|
49
|
+
'slot-has-content': this.slotHasContent,
|
|
50
|
+
})}
|
|
51
|
+
>
|
|
52
|
+
<div class="line"></div>
|
|
53
|
+
<div class="slot-container">
|
|
54
|
+
<slot></slot>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="line"></div>
|
|
57
|
+
</div>`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#handleSlotChange(event: { target: any }) {
|
|
61
|
+
const slot = event.target;
|
|
62
|
+
// Check assignedElements length
|
|
63
|
+
this.slotHasContent = slot.assignedNodes({ flatten: true }).length > 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Divider } from './divider.js';
|
package/src/icon/demo/index.html
CHANGED
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
<body>
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
<
|
|
17
|
-
<
|
|
16
|
+
<p-icon></p-icon>
|
|
17
|
+
<p-icon provider='carbon' name='logo--github'></p-icon>
|
|
18
18
|
|
|
19
19
|
<script type='module'>
|
|
20
|
-
import { Icon } from '/dist/
|
|
20
|
+
import { Icon } from '/dist/index.js';
|
|
21
21
|
|
|
22
|
-
window.customElements.define('
|
|
22
|
+
window.customElements.define('p-icon', Icon);
|
|
23
23
|
</script>
|
|
24
24
|
</body>
|
|
25
25
|
</html>
|
package/src/icon/icon.ts
CHANGED
|
@@ -6,19 +6,33 @@ import { sanitizeSvg } from '../utils.js';
|
|
|
6
6
|
import { styles } from './icon.css.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
+
* @label Icon
|
|
10
|
+
* @tag p-icon
|
|
11
|
+
* @rawTag icon
|
|
9
12
|
* @summary Icons are visual symbols used to represent ideas, objects, or actions.
|
|
13
|
+
* @overview Icons are visual symbols used to represent ideas, objects, or actions. They communicate messages at a glance, afford interactivity, and draw attention to important information.
|
|
10
14
|
*
|
|
11
15
|
* @cssprop --icon-color - Controls the color of the icon.
|
|
12
16
|
* @cssprop [--icon-size=1rem] - Controls the size of the icon. Defaults to "1rem"
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```html
|
|
20
|
+
* <p-icon name="home"></p-icon>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
13
23
|
*/
|
|
14
24
|
export class Icon extends LitElement {
|
|
15
25
|
static styles = [styles];
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The identifier for the icon.
|
|
29
|
+
* This name corresponds to a specific SVG asset in the icon set.
|
|
30
|
+
*/
|
|
31
|
+
@property({ type: String, reflect: true }) name?: string;
|
|
18
32
|
|
|
19
33
|
@property({ type: String, reflect: true }) src?: string;
|
|
20
34
|
|
|
21
|
-
@property({ type: String }) provider
|
|
35
|
+
@property({ type: String }) provider: 'material-symbols' | 'carbon' =
|
|
22
36
|
'material-symbols';
|
|
23
37
|
|
|
24
38
|
@state()
|
package/src/icon/p-icon.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export { Icon } from './icon/
|
|
2
|
-
export { Avatar } from './avatar/
|
|
1
|
+
export { Icon } from './icon/index.js';
|
|
2
|
+
export { Avatar } from './avatar/index.js';
|
|
3
|
+
export { Badge } from './badge/index.js';
|
|
4
|
+
export { Divider } from './divider/index.js';
|
|
5
|
+
export { Clock } from './clock/index.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { css, unsafeCSS, CSSResult } from 'lit';
|
|
2
|
+
import { focusRing } from '../styleMixins.css.js';
|
|
3
|
+
|
|
4
|
+
export const createLinkStyles = (prefix: string): CSSResult => css`
|
|
5
|
+
.${unsafeCSS(prefix)}-link {
|
|
6
|
+
border-radius: inherit;
|
|
7
|
+
corner-shape: inherit;
|
|
8
|
+
|
|
9
|
+
color: var(--color-primary);
|
|
10
|
+
--icon-color: var(--color-primary);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.${unsafeCSS(prefix)}-link:hover {
|
|
14
|
+
color: var(--color-on-primary-container);
|
|
15
|
+
--icon-color: var(--color-on-primary-container);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.${unsafeCSS(prefix)}-link:focus {
|
|
19
|
+
text-decoration: none;
|
|
20
|
+
${focusRing()}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.${unsafeCSS(prefix)}-link.no-style {
|
|
24
|
+
color: var(--color-on-surface);
|
|
25
|
+
--icon-color: var(--color-on-surface);
|
|
26
|
+
text-decoration: none !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.${unsafeCSS(prefix)}-link.no-decoration {
|
|
30
|
+
text-decoration: none !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.${unsafeCSS(prefix)}-link.inline {
|
|
34
|
+
text-decoration: var(--link-decoration, underline);
|
|
35
|
+
}
|
|
36
|
+
`;
|
package/src/peacock-loader.ts
CHANGED
|
@@ -1,15 +1,62 @@
|
|
|
1
1
|
// Eager loaded
|
|
2
|
+
import cssComponentsStyleSheet from '@redvars/peacock-design-tokens/dist/tokens.css';
|
|
2
3
|
import { Icon } from './icon/icon.js';
|
|
4
|
+
import { Avatar } from './avatar/avatar.js';
|
|
5
|
+
import { Badge } from './badge/badge.js';
|
|
6
|
+
import { Divider } from './divider/divider.js';
|
|
7
|
+
|
|
3
8
|
import { LoaderConfig, LoaderUtils } from './LoaderUtils.js';
|
|
9
|
+
import { createLinkStyles } from './link/link.css.js';
|
|
10
|
+
import { createTextStyles } from './text/text.css.js';
|
|
11
|
+
|
|
12
|
+
const libraryPrefix = 'p';
|
|
13
|
+
|
|
14
|
+
function buildSheet(styleSheet: any) {
|
|
15
|
+
const sheet = new CSSStyleSheet();
|
|
16
|
+
// Add rules
|
|
17
|
+
sheet.replaceSync(styleSheet.toString());
|
|
18
|
+
return sheet;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const styleSheets = [buildSheet(cssComponentsStyleSheet)];
|
|
22
|
+
|
|
23
|
+
const linkStylesheet = createLinkStyles(libraryPrefix).styleSheet;
|
|
24
|
+
if (linkStylesheet) styleSheets.push(linkStylesheet);
|
|
25
|
+
|
|
26
|
+
const textStylesheet = createTextStyles(libraryPrefix).styleSheet;
|
|
27
|
+
if (textStylesheet) styleSheets.push(textStylesheet);
|
|
28
|
+
|
|
29
|
+
function stringifyStyleSheet(stylesheet: any) {
|
|
30
|
+
// Use Array.from() to convert the CSSRuleList to an array
|
|
31
|
+
return (
|
|
32
|
+
Array.from(stylesheet.cssRules)
|
|
33
|
+
// Map each rule to its cssText property
|
|
34
|
+
.map((rule: any) => rule.cssText || '')
|
|
35
|
+
// Join all the rules with a newline character
|
|
36
|
+
.join('\\n')
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
document.adoptedStyleSheets = styleSheets;
|
|
4
41
|
|
|
5
42
|
const loaderConfig: LoaderConfig = {
|
|
6
|
-
prefix:
|
|
43
|
+
prefix: libraryPrefix,
|
|
7
44
|
components: {
|
|
8
45
|
icon: {
|
|
9
46
|
CustomElementClass: Icon,
|
|
47
|
+
// importPath: './component/icon.js', - for lazy load give path instead of CustomElementClass
|
|
10
48
|
},
|
|
11
49
|
avatar: {
|
|
12
|
-
|
|
50
|
+
CustomElementClass: Avatar,
|
|
51
|
+
},
|
|
52
|
+
badge: {
|
|
53
|
+
CustomElementClass: Badge,
|
|
54
|
+
},
|
|
55
|
+
divider: {
|
|
56
|
+
CustomElementClass: Divider,
|
|
57
|
+
},
|
|
58
|
+
clock: {
|
|
59
|
+
importPath: '.' + '/clock.js',
|
|
13
60
|
},
|
|
14
61
|
},
|
|
15
62
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { css, unsafeCSS, CSSResult } from 'lit';
|
|
2
|
+
|
|
3
|
+
export const focusRing = (
|
|
4
|
+
color = 'var(--border-interactive)',
|
|
5
|
+
): CSSResult => css`
|
|
6
|
+
outline: 2px solid ${unsafeCSS(color)};
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
export const getTypography = (name: string): CSSResult => css`
|
|
10
|
+
font-family: var(--typography-${unsafeCSS(name)}-font-family) !important;
|
|
11
|
+
font-size: var(--typography-${unsafeCSS(name)}-font-size) !important;
|
|
12
|
+
font-weight: var(--typography-${unsafeCSS(name)}-font-weight) !important;
|
|
13
|
+
line-height: var(--typography-${unsafeCSS(name)}-line-height) !important;
|
|
14
|
+
letter-spacing: var(
|
|
15
|
+
--typography-${unsafeCSS(name)}-letter-spacing
|
|
16
|
+
) !important;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export const getTypographyNotImportant = (name: string): CSSResult => css`
|
|
20
|
+
font-family: var(--typography-${unsafeCSS(name)}-font-family);
|
|
21
|
+
font-size: var(--typography-${unsafeCSS(name)}-font-size);
|
|
22
|
+
font-weight: var(--typography-${unsafeCSS(name)}-font-weight);
|
|
23
|
+
line-height: var(--typography-${unsafeCSS(name)}-line-height);
|
|
24
|
+
letter-spacing: var(--typography-${unsafeCSS(name)}-letter-spacing);
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const forPhoneOnly = (content: CSSResult): CSSResult => css`
|
|
28
|
+
@media (max-width: 671px) {
|
|
29
|
+
${content}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
export const forTabletPortraitUp = (content: CSSResult): CSSResult => css`
|
|
34
|
+
@media (min-width: 672px) {
|
|
35
|
+
${content}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
export const forTabletLandscapeUp = (content: CSSResult): CSSResult => css`
|
|
40
|
+
@media (min-width: 1056px) {
|
|
41
|
+
${content}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export const forDesktopUp = (content: CSSResult): CSSResult => css`
|
|
46
|
+
@media (min-width: 1312px) {
|
|
47
|
+
${content}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export const forBigDesktopUp = (content: CSSResult): CSSResult => css`
|
|
52
|
+
@media (min-width: 1584px) {
|
|
53
|
+
${content}
|
|
54
|
+
}
|
|
55
|
+
`;
|
package/src/styles.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { css, unsafeCSS, CSSResult } from 'lit';
|
|
2
|
+
import { getTypography } from '../styleMixins.css.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Sass equivalents:
|
|
6
|
+
* $types: "display", "headline", "body", "code", "label", "title";
|
|
7
|
+
* $sizes: "large", "medium", "small";
|
|
8
|
+
*/
|
|
9
|
+
const TYPES = [
|
|
10
|
+
'display',
|
|
11
|
+
'headline',
|
|
12
|
+
'body',
|
|
13
|
+
'code',
|
|
14
|
+
'label',
|
|
15
|
+
'title',
|
|
16
|
+
] as const;
|
|
17
|
+
|
|
18
|
+
const SIZES = ['large', 'medium', 'small'] as const;
|
|
19
|
+
|
|
20
|
+
const createTagClass = (prefix: string, tag: string) => css`
|
|
21
|
+
.${unsafeCSS(prefix)}-text-${unsafeCSS(tag)} {
|
|
22
|
+
${getTypography(tag)}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.${unsafeCSS(prefix)}-text-${unsafeCSS(tag)}-emphasized {
|
|
26
|
+
${getTypography(`${tag}-emphasized`)}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const createTypeClass = (prefix: string, type: string) => css`
|
|
31
|
+
.${unsafeCSS(prefix)}-text-${unsafeCSS(type)} {
|
|
32
|
+
${getTypography(`${type}-medium`)}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.${unsafeCSS(prefix)}-text-${unsafeCSS(type)}-emphasized {
|
|
36
|
+
${getTypography(`${type}-medium-emphasized`)}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
${unsafeCSS(
|
|
40
|
+
SIZES.map(size => createTagClass(prefix, `${type}-${size}`)).join(''),
|
|
41
|
+
)}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export const createTextStyles = (prefix: string): CSSResult => css`
|
|
45
|
+
/* === Margin rules (manual groups from Sass) === */
|
|
46
|
+
|
|
47
|
+
.${unsafeCSS(prefix)}-text-body,
|
|
48
|
+
.${unsafeCSS(prefix)}-text-body-medium,
|
|
49
|
+
.${unsafeCSS(prefix)}-text-body-large,
|
|
50
|
+
.${unsafeCSS(prefix)}-text-body-small {
|
|
51
|
+
margin-block-end: var(--spacing-200);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.${unsafeCSS(prefix)}-text-headline,
|
|
55
|
+
.${unsafeCSS(prefix)}-text-headline-medium,
|
|
56
|
+
.${unsafeCSS(prefix)}-text-headline-large,
|
|
57
|
+
.${unsafeCSS(prefix)}-text-headline-small {
|
|
58
|
+
margin-block-end: var(--spacing-400);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.${unsafeCSS(prefix)}-text-display,
|
|
62
|
+
.${unsafeCSS(prefix)}-text-display-medium,
|
|
63
|
+
.${unsafeCSS(prefix)}-text-display-large,
|
|
64
|
+
.${unsafeCSS(prefix)}-text-display-small {
|
|
65
|
+
margin-block-end: var(--spacing-400);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.${unsafeCSS(prefix)}-text-title,
|
|
69
|
+
.${unsafeCSS(prefix)}-text-title-medium,
|
|
70
|
+
.${unsafeCSS(prefix)}-text-title-large,
|
|
71
|
+
.${unsafeCSS(prefix)}-text-title-small {
|
|
72
|
+
margin-block-end: var(--spacing-400);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
${unsafeCSS(TYPES.map(type => createTypeClass(prefix, type)).join(''))}
|
|
76
|
+
`;
|
package/src/utils.ts
CHANGED
|
@@ -109,10 +109,45 @@ export function sanitizeSvg(rawSvg: string) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
function __hasMeaningfulContent(slotElement: any) {
|
|
113
|
+
const nodes = slotElement.assignedNodes({ flatten: true });
|
|
114
|
+
|
|
115
|
+
for (const node of nodes) {
|
|
116
|
+
// If it's an element node, it has content
|
|
117
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
// If it's a text node and contains non-whitespace characters, it has content
|
|
121
|
+
if (
|
|
122
|
+
node.nodeType === Node.TEXT_NODE &&
|
|
123
|
+
node.textContent.trim().length > 0
|
|
124
|
+
) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// No meaningful content found
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function observerSlotChangesWithCallback(
|
|
134
|
+
slot: HTMLSlotElement | null,
|
|
135
|
+
callback: (hasContent: boolean) => void,
|
|
136
|
+
) {
|
|
137
|
+
const observer = new MutationObserver(() => {
|
|
138
|
+
callback(__hasMeaningfulContent(slot));
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Observe the elements currently assigned to the slot
|
|
142
|
+
const assignedNodes = slot?.assignedNodes({ flatten: true }) || [];
|
|
143
|
+
assignedNodes.forEach(node => {
|
|
144
|
+
observer.observe(node, {
|
|
145
|
+
attributes: true,
|
|
146
|
+
childList: true,
|
|
147
|
+
characterData: true,
|
|
148
|
+
subtree: true,
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
callback(__hasMeaningfulContent(slot));
|
|
153
|
+
}
|
package/tsconfig.json
CHANGED
package/README.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# `src/Icon.ts`:
|
|
2
|
-
|
|
3
|
-
## class: `Icon`
|
|
4
|
-
|
|
5
|
-
### Superclass
|
|
6
|
-
|
|
7
|
-
| Name | Module | Package |
|
|
8
|
-
| ------------ | ------ | ------- |
|
|
9
|
-
| `LitElement` | | lit |
|
|
10
|
-
|
|
11
|
-
### Fields
|
|
12
|
-
|
|
13
|
-
| Name | Privacy | Type | Default | Description | Inherited From |
|
|
14
|
-
| ---------- | ------- | --------------------------------------------- | -------------------- | ----------- | -------------- |
|
|
15
|
-
| `name` | | `string \| undefined` | `'home'` | | |
|
|
16
|
-
| `src` | | `string \| undefined` | | | |
|
|
17
|
-
| `provider` | | `'material-symbols' \| 'carbon' \| undefined` | `'material-symbols'` | | |
|
|
18
|
-
|
|
19
|
-
### Events
|
|
20
|
-
|
|
21
|
-
| Name | Type | Description | Inherited From |
|
|
22
|
-
| ------------ | ------------- | ----------- | -------------- |
|
|
23
|
-
| `icon-error` | `CustomEvent` | | |
|
|
24
|
-
|
|
25
|
-
### Attributes
|
|
26
|
-
|
|
27
|
-
| Name | Field | Inherited From |
|
|
28
|
-
| ---------- | -------- | -------------- |
|
|
29
|
-
| `name` | name | |
|
|
30
|
-
| `src` | src | |
|
|
31
|
-
| `provider` | provider | |
|
|
32
|
-
|
|
33
|
-
### CSS Properties
|
|
34
|
-
|
|
35
|
-
| Name | Default | Description |
|
|
36
|
-
| -------------- | ------- | ------------------------------- |
|
|
37
|
-
| `--icon-color` | | Controls the color of the icon. |
|
|
38
|
-
| `--icon-size` | | Controls the size of the icon. |
|
|
39
|
-
|
|
40
|
-
<hr/>
|
|
41
|
-
|
|
42
|
-
## Exports
|
|
43
|
-
|
|
44
|
-
| Kind | Name | Declaration | Module | Package |
|
|
45
|
-
| ---- | ------ | ----------- | ----------- | ------- |
|
|
46
|
-
| `js` | `Icon` | Icon | src/Icon.ts | |
|