mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-19 07:29:14 +00:00
Compare commits
3 Commits
include-er
...
styling-at
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc775fd2b9 | ||
|
|
96fd2941df | ||
|
|
6644288f2b |
@@ -31,13 +31,25 @@ const components = manifest.modules.flatMap(module => {
|
|||||||
return prop.kind === 'field' && prop.privacy !== 'private';
|
return prop.kind === 'field' && prop.privacy !== 'private';
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
let ret = {
|
||||||
...declaration,
|
...declaration,
|
||||||
slug: declaration.tagName.replace(/^wa-/, ''),
|
slug: declaration.tagName.replace(/^wa-/, ''),
|
||||||
methods,
|
methods,
|
||||||
attributes,
|
attributes,
|
||||||
properties,
|
properties,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add named keys to these arrays
|
||||||
|
for (let thing of ['methods', 'attributes', 'properties', 'cssProperties', 'cssParts', 'cssStates', 'events']) {
|
||||||
|
if (ret[thing]) {
|
||||||
|
ret[thing] = ret[thing].reduce((acc, item) => {
|
||||||
|
acc[item.name] = item;
|
||||||
|
return acc;
|
||||||
|
}, ret[thing]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,18 @@ export function trimPipes(content) {
|
|||||||
return typeof content === 'string' ? content.replace(/^(\s|\|)/g, '').replace(/(\s|\|)$/g, '') : content;
|
return typeof content === 'string' ? content.replace(/^(\s|\|)/g, '').replace(/(\s|\|)$/g, '') : content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function stripQuotes(content) {
|
||||||
|
return content.replace(/^(['"])(.+)\1$/g, '$2');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getEnumValues(type) {
|
||||||
|
return type
|
||||||
|
.split('|')
|
||||||
|
.map(value => value.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
.map(stripQuotes);
|
||||||
|
}
|
||||||
|
|
||||||
export function keys(obj) {
|
export function keys(obj) {
|
||||||
return Object.keys(obj);
|
return Object.keys(obj);
|
||||||
}
|
}
|
||||||
|
|||||||
36
docs/docs/test/styling.njk
Normal file
36
docs/docs/test/styling.njk
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
title: Styling Tests
|
||||||
|
---
|
||||||
|
|
||||||
|
<h2>Appearance and variant tests</h2>
|
||||||
|
|
||||||
|
{% for component in componentsBy.attribute.variant %}
|
||||||
|
{%- if component.attributes.appearance -%}
|
||||||
|
<h3><a href="../{{ component.url }}"><code><{{ component.tagName }}></code></a></h3>
|
||||||
|
|
||||||
|
{% set variantValues = component.attributes.variant.type.text | getEnumValues %}
|
||||||
|
{% set appearanceValues = component.attributes.appearance.type.text | getEnumValues %}
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Variant</th>
|
||||||
|
{% for appearance in appearanceValues %}
|
||||||
|
<th>{{ appearance }}</th>
|
||||||
|
{%- endfor %}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for variant in variantValues %}
|
||||||
|
<tr>
|
||||||
|
<th>{{ variant }}</th>
|
||||||
|
{% for appearance in appearanceValues %}
|
||||||
|
<td>
|
||||||
|
<{{ component.tagName }} variant={{ variant }} appearance={{ appearance }}>{{ variant }} {{ appearance }}</{{ component.tagName }}>
|
||||||
|
</td>
|
||||||
|
{%- endfor %}
|
||||||
|
</tr>
|
||||||
|
{%- endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{%- endfor %}
|
||||||
@@ -5,13 +5,18 @@ import { html, literal } from 'lit/static-html.js';
|
|||||||
import { WaBlurEvent } from '../../events/blur.js';
|
import { WaBlurEvent } from '../../events/blur.js';
|
||||||
import { WaFocusEvent } from '../../events/focus.js';
|
import { WaFocusEvent } from '../../events/focus.js';
|
||||||
import { WaInvalidEvent } from '../../events/invalid.js';
|
import { WaInvalidEvent } from '../../events/invalid.js';
|
||||||
|
import {
|
||||||
|
appearanceStyles,
|
||||||
|
sizeStyles,
|
||||||
|
variantStyles,
|
||||||
|
type AppearanceAttribute,
|
||||||
|
type SizeAttribute,
|
||||||
|
type VariantAttribute,
|
||||||
|
} from '../../internal/styling-attributes.js';
|
||||||
import { MirrorValidator } from '../../internal/validators/mirror-validator.js';
|
import { MirrorValidator } from '../../internal/validators/mirror-validator.js';
|
||||||
import { watch } from '../../internal/watch.js';
|
import { watch } from '../../internal/watch.js';
|
||||||
import { WebAwesomeFormAssociatedElement } from '../../internal/webawesome-formassociated-element.js';
|
import { WebAwesomeFormAssociatedElement } from '../../internal/webawesome-formassociated-element.js';
|
||||||
import nativeStyles from '../../styles/native/button.css';
|
import nativeStyles from '../../styles/native/button.css';
|
||||||
import appearanceStyles from '../../styles/utilities/appearance.css';
|
|
||||||
import sizeStyles from '../../styles/utilities/size.css';
|
|
||||||
import variantStyles from '../../styles/utilities/variants.css';
|
|
||||||
import { LocalizeController } from '../../utilities/localize.js';
|
import { LocalizeController } from '../../utilities/localize.js';
|
||||||
import '../icon/icon.js';
|
import '../icon/icon.js';
|
||||||
import '../spinner/spinner.js';
|
import '../spinner/spinner.js';
|
||||||
@@ -69,13 +74,13 @@ export default class WaButton extends WebAwesomeFormAssociatedElement {
|
|||||||
@property() title = ''; // make reactive to pass through
|
@property() title = ''; // make reactive to pass through
|
||||||
|
|
||||||
/** The button's theme variant. */
|
/** The button's theme variant. */
|
||||||
@property({ reflect: true }) variant: 'neutral' | 'brand' | 'success' | 'warning' | 'danger' = 'neutral';
|
@property({ reflect: true }) variant: VariantAttribute = 'neutral';
|
||||||
|
|
||||||
/** The button's visual appearance. */
|
/** The button's visual appearance. */
|
||||||
@property({ reflect: true }) appearance: 'accent' | 'filled' | 'outlined' | 'plain' = 'accent';
|
@property({ reflect: true }) appearance: AppearanceAttribute = 'accent';
|
||||||
|
|
||||||
/** The button's size. */
|
/** The button's size. */
|
||||||
@property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';
|
@property({ reflect: true }) size: SizeAttribute = 'medium';
|
||||||
|
|
||||||
/** Draws the button with a caret. Used to indicate that the button triggers a dropdown menu or similar behavior. */
|
/** Draws the button with a caret. Used to indicate that the button triggers a dropdown menu or similar behavior. */
|
||||||
@property({ type: Boolean, reflect: true }) caret = false;
|
@property({ type: Boolean, reflect: true }) caret = false;
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { customElement, property } from 'lit/decorators.js';
|
||||||
import { WaRemoveEvent } from '../../events/remove.js';
|
import { WaRemoveEvent } from '../../events/remove.js';
|
||||||
|
import {
|
||||||
|
appearanceStyles,
|
||||||
|
sizeStyles,
|
||||||
|
variantStyles,
|
||||||
|
type AppearanceAttribute,
|
||||||
|
type SizeAttribute,
|
||||||
|
type VariantAttribute,
|
||||||
|
} from '../../internal/styling-attributes.js';
|
||||||
import WebAwesomeElement from '../../internal/webawesome-element.js';
|
import WebAwesomeElement from '../../internal/webawesome-element.js';
|
||||||
import appearanceStyles from '../../styles/utilities/appearance.css';
|
|
||||||
import sizeStyles from '../../styles/utilities/size.css';
|
|
||||||
import variantStyles from '../../styles/utilities/variants.css';
|
|
||||||
import { LocalizeController } from '../../utilities/localize.js';
|
import { LocalizeController } from '../../utilities/localize.js';
|
||||||
import '../icon-button/icon-button.js';
|
import '../icon-button/icon-button.js';
|
||||||
import styles from './tag.css';
|
import styles from './tag.css';
|
||||||
@@ -33,14 +38,13 @@ export default class WaTag extends WebAwesomeElement {
|
|||||||
private readonly localize = new LocalizeController(this);
|
private readonly localize = new LocalizeController(this);
|
||||||
|
|
||||||
/** The tag's theme variant. */
|
/** The tag's theme variant. */
|
||||||
@property({ reflect: true }) variant: 'brand' | 'success' | 'neutral' | 'warning' | 'danger' | 'text' = 'neutral';
|
@property({ reflect: true }) variant: VariantAttribute = 'neutral';
|
||||||
|
|
||||||
/** The tag's visual appearance. */
|
/** The tag's visual appearance. */
|
||||||
@property({ reflect: true }) appearance: 'accent' | 'outlined accent' | 'filled' | 'outlined' | 'outlined filled' =
|
@property({ reflect: true }) appearance: AppearanceAttribute = 'outlined filled';
|
||||||
'outlined filled';
|
|
||||||
|
|
||||||
/** The tag's size. */
|
/** The tag's size. */
|
||||||
@property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';
|
@property({ reflect: true }) size: SizeAttribute = 'medium';
|
||||||
|
|
||||||
/** Draws a pill-style tag with rounded edges. */
|
/** Draws a pill-style tag with rounded edges. */
|
||||||
@property({ type: Boolean, reflect: true }) pill = false;
|
@property({ type: Boolean, reflect: true }) pill = false;
|
||||||
|
|||||||
16
src/internal/styling-attributes.ts
Normal file
16
src/internal/styling-attributes.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
export { default as appearanceStyles } from '../styles/utilities/appearance.css';
|
||||||
|
export { default as sizeStyles } from '../styles/utilities/size.css';
|
||||||
|
export { default as variantStyles } from '../styles/utilities/variants.css';
|
||||||
|
|
||||||
|
export type AppearanceAttribute =
|
||||||
|
| 'outlined'
|
||||||
|
| 'accent'
|
||||||
|
| 'outlined accent'
|
||||||
|
| 'accent outlined'
|
||||||
|
| 'filled'
|
||||||
|
| 'outlined filled'
|
||||||
|
| 'filled outlined'
|
||||||
|
| 'plain';
|
||||||
|
|
||||||
|
export type VariantAttribute = 'brand' | 'success' | 'neutral' | 'warning' | 'danger' | 'text';
|
||||||
|
export type SizeAttribute = 'small' | 'medium' | 'large';
|
||||||
Reference in New Issue
Block a user