/** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import '@material/web/field/filled-field.js'; import '@material/web/field/outlined-field.js'; import '@material/web/icon/icon.js'; import {MaterialStoryInit} from './material-collection.js'; import {css, html, nothing} from 'lit'; import {styleMap} from 'lit/directives/style-map.js'; /** Knob types for field stories. */ export interface StoryKnobs { label: string; 'Supporting text': string; 'Error text': string; disabled: boolean; error: boolean; focused: boolean; populated: boolean; required: boolean; noAsterisk: boolean; 'Leading icon': boolean; 'Trailing icon': boolean; resizable: boolean; count: number; max: number; } const START_CONTENT = html`search`; const END_CONTENT = html`event`; const styles = css` md-filled-field, md-outlined-field { width: 256px; } `; const filled: MaterialStoryInit = { name: 'Filled', styles, render(knobs) { const { label, disabled, error, focused, noAsterisk, populated, required, resizable, count, max, } = knobs; const supportingText = knobs['Supporting text']; const errorText = knobs['Error text']; const hasStart = knobs['Leading icon']; const hasEnd = knobs['Trailing icon']; const content = resizable ? html`` : html``; const styles = {resize: resizable ? 'both' : null}; return html` ${hasStart ? START_CONTENT : nothing} ${content} ${hasEnd ? END_CONTENT : nothing} `; }, }; const outlined: MaterialStoryInit = { name: 'Outlined', styles, render(knobs) { const { label, disabled, error, focused, noAsterisk, populated, required, resizable, count, max, } = knobs; const supportingText = knobs['Supporting text']; const errorText = knobs['Error text']; const hasStart = knobs['Leading icon']; const hasEnd = knobs['Trailing icon']; const content = resizable ? html`` : html``; const styles = {resize: resizable ? 'both' : null}; return html` ${hasStart ? START_CONTENT : nothing} ${content} ${hasEnd ? END_CONTENT : nothing} `; }, }; /** Field stories. */ export const stories = [filled, outlined];