change every button in lib/cli/renderassets and renderer/*/template to use the label prop

This commit is contained in:
Norbert de Langen 2022-10-12 12:02:30 +02:00
parent 6d490107b3
commit 764697fc93
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762
29 changed files with 80 additions and 80 deletions

View File

@ -7,26 +7,26 @@ export default {
title: 'Button', title: 'Button',
// More on argTypes: https://storybook.js.org/docs/ember/api/argtypes // More on argTypes: https://storybook.js.org/docs/ember/api/argtypes
argTypes: { argTypes: {
children: { control: 'text' }, label: { control: 'text' },
}, },
}; };
// More on component templates: https://storybook.js.org/docs/ember/writing-stories/introduction#using-args // More on component templates: https://storybook.js.org/docs/ember/writing-stories/introduction#using-args
const Template = (args) => ({ const Template = (args) => ({
template: hbs`<button {{action onClick}}>{{children}}</button>`, template: hbs`<button {{action onClick}}>{{label}}</button>`,
context: args, context: args,
}); });
export const Text = Template.bind({}); export const Text = Template.bind({});
// More on args: https://storybook.js.org/docs/ember/writing-stories/args // More on args: https://storybook.js.org/docs/ember/writing-stories/args
Text.args = { Text.args = {
children: 'Button', label: 'Button',
onClick: action('onClick'), onClick: action('onClick'),
}; };
export const Emoji = Template.bind({}); export const Emoji = Template.bind({});
Emoji.args = { Emoji.args = {
children: '😀 😎 👍 💯', label: '😀 😎 👍 💯',
}; };
export const TextWithAction = () => ({ export const TextWithAction = () => ({

View File

@ -6,7 +6,7 @@ export default {
title: 'Button', title: 'Button',
// More on argTypes: https://storybook.js.org/docs/marko/api/argtypes // More on argTypes: https://storybook.js.org/docs/marko/api/argtypes
argTypes: { argTypes: {
children: { control: 'text' }, label: { control: 'text' },
}, },
}; };
@ -19,6 +19,6 @@ const Template = (args) => ({
export const Text = Template.bind({}); export const Text = Template.bind({});
// More on args: https://storybook.js.org/docs/marko/writing-stories/args // More on args: https://storybook.js.org/docs/marko/writing-stories/args
Text.args = { Text.args = {
children: 'Button', label: 'Button',
onClick: action('onClick'), onClick: action('onClick'),
}; };

View File

@ -9,5 +9,5 @@ class {
} }
<div> <div>
<button type="button" on-click("handleClick")>${input.children}</button> <button type="button" on-click("handleClick")>${input.label}</button>
</div> </div>

View File

@ -4,7 +4,7 @@ import m from 'mithril';
import './button.css'; import './button.css';
export const Button = { export const Button = {
view: ({ children, attrs }) => { view: ({ label, attrs }) => {
const mode = attrs.primary ? 'storybook-button--primary' : 'storybook-button--secondary'; const mode = attrs.primary ? 'storybook-button--primary' : 'storybook-button--secondary';
const size = attrs.size || 'medium'; const size = attrs.size || 'medium';
@ -15,7 +15,7 @@ export const Button = {
style={attrs.backgroundColor && { backgroundColor: attrs.backgroundColor }} style={attrs.backgroundColor && { backgroundColor: attrs.backgroundColor }}
onclick={attrs.onClick} onclick={attrs.onClick}
> >
{children} {label}
</button> </button>
); );
}, },

View File

@ -14,30 +14,30 @@ export default {
}; };
// More on component templates: https://storybook.js.org/docs/mithril/writing-stories/introduction#using-args // More on component templates: https://storybook.js.org/docs/mithril/writing-stories/introduction#using-args
const Template = ({ children, ...args }) => ({ const Template = ({ label, ...args }) => ({
view: () => m(Button, args, children), view: () => m(Button, args, label),
}); });
export const Primary = Template.bind({}); export const Primary = Template.bind({});
// More on args: https://storybook.js.org/docs/mithril/writing-stories/args // More on args: https://storybook.js.org/docs/mithril/writing-stories/args
Primary.args = { Primary.args = {
primary: true, primary: true,
children: 'Button', label: 'Button',
}; };
export const Secondary = Template.bind({}); export const Secondary = Template.bind({});
Secondary.args = { Secondary.args = {
children: 'Button', label: 'Button',
}; };
export const Large = Template.bind({}); export const Large = Template.bind({});
Large.args = { Large.args = {
size: 'large', size: 'large',
children: 'Button', label: 'Button',
}; };
export const Small = Template.bind({}); export const Small = Template.bind({});
Small.args = { Small.args = {
size: 'small', size: 'small',
children: 'Button', label: 'Button',
}; };

View File

@ -7,8 +7,8 @@ export default {
component: Header, component: Header,
}; };
const Template = ({ children, ...args }) => ({ const Template = ({ label, ...args }) => ({
view: () => m(Header, args, children), view: () => m(Header, args, label),
}); });
export const LoggedIn = Template.bind({}); export const LoggedIn = Template.bind({});

View File

@ -8,8 +8,8 @@ export default {
component: Page, component: Page,
}; };
const Template = ({ children, ...args }) => ({ const Template = ({ label, ...args }) => ({
view: () => m(Page, args, children), view: () => m(Page, args, label),
}); });
export const LoggedIn = Template.bind({}); export const LoggedIn = Template.bind({});

View File

@ -25,22 +25,22 @@ export const Primary = Template.bind({});
// More on args: https://storybook.js.org/docs/vue/writing-stories/args // More on args: https://storybook.js.org/docs/vue/writing-stories/args
Primary.args = { Primary.args = {
primary: true, primary: true,
children: 'Button', label: 'Button',
}; };
export const Secondary = Template.bind({}); export const Secondary = Template.bind({});
Secondary.args = { Secondary.args = {
children: 'Button', label: 'Button',
}; };
export const Large = Template.bind({}); export const Large = Template.bind({});
Large.args = { Large.args = {
size: 'large', size: 'large',
children: 'Button', label: 'Button',
}; };
export const Small = Template.bind({}); export const Small = Template.bind({});
Small.args = { Small.args = {
size: 'small', size: 'small',
children: 'Button', label: 'Button',
}; };

View File

@ -1,5 +1,5 @@
<template> <template>
<button type="button" :class="classes" @click="onClick" :style="style">{{ children }}</button> <button type="button" :class="classes" @click="onClick" :style="style">{{ label }}</button>
</template> </template>
<script> <script>
@ -9,7 +9,7 @@ export default {
name: 'my-button', name: 'my-button',
props: { props: {
children: { label: {
type: String, type: String,
required: true, required: true,
}, },

View File

@ -13,9 +13,9 @@
</div> </div>
<div> <div>
<span class="welcome" v-if="user">Welcome, <b>{{ user.name }}</b>!</span> <span class="welcome" v-if="user">Welcome, <b>{{ user.name }}</b>!</span>
<my-button size="small" @onClick="onLogout" children="Log out" v-if="user" /> <my-button size="small" @onClick="onLogout" label="Log out" v-if="user" />
<my-button size="small" @onClick="onLogin" children="Log in" v-if="!user" /> <my-button size="small" @onClick="onLogin" label="Log in" v-if="!user" />
<my-button primary size="small" @onClick="onCreateAccount" children="Sign up" v-if="!user" /> <my-button primary size="small" @onClick="onCreateAccount" label="Sign up" v-if="!user" />
</div> </div>
</div> </div>
</header> </header>

View File

@ -31,22 +31,22 @@ export const Primary = Template.bind({});
// More on args: https://storybook.js.org/docs/vue/writing-stories/args // More on args: https://storybook.js.org/docs/vue/writing-stories/args
Primary.args = { Primary.args = {
primary: true, primary: true,
children: 'Button', label: 'Button',
}; };
export const Secondary = Template.bind({}); export const Secondary = Template.bind({});
Secondary.args = { Secondary.args = {
children: 'Button', label: 'Button',
}; };
export const Large = Template.bind({}); export const Large = Template.bind({});
Large.args = { Large.args = {
size: 'large', size: 'large',
children: 'Button', label: 'Button',
}; };
export const Small = Template.bind({}); export const Small = Template.bind({});
Small.args = { Small.args = {
size: 'small', size: 'small',
children: 'Button', label: 'Button',
}; };

View File

@ -1,5 +1,5 @@
<template> <template>
<button type="button" :class="classes" @click="onClick" :style="style">{{ children }}</button> <button type="button" :class="classes" @click="onClick" :style="style">{{ label }}</button>
</template> </template>
<script> <script>
@ -10,7 +10,7 @@ export default {
name: 'my-button', name: 'my-button',
props: { props: {
children: { label: {
type: String, type: String,
required: true, required: true,
}, },

View File

@ -13,9 +13,9 @@
</div> </div>
<div> <div>
<span class="welcome" v-if="user">Welcome, <b>{{ user.name }}</b>!</span> <span class="welcome" v-if="user">Welcome, <b>{{ user.name }}</b>!</span>
<my-button size="small" @click="$emit('logout')" children="Log out" v-if="user" /> <my-button size="small" @click="$emit('logout')" label="Log out" v-if="user" />
<my-button size="small" @click="$emit('login')" children="Log in" v-if="!user" /> <my-button size="small" @click="$emit('login')" label="Log in" v-if="!user" />
<my-button primary size="small" @click="$emit('createAccount')" children="Sign up" v-if="!user" /> <my-button primary size="small" @click="$emit('createAccount')" label="Sign up" v-if="!user" />
</div> </div>
</div> </div>
</header> </header>

View File

@ -2,16 +2,16 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { TouchableHighlight } from 'react-native'; import { TouchableHighlight } from 'react-native';
export default function Button({ onPress, children }) { export default function Button({ onPress, label }) {
return <TouchableHighlight onPress={onPress}>{children}</TouchableHighlight>; return <TouchableHighlight onPress={onPress}>{label}</TouchableHighlight>;
} }
Button.defaultProps = { Button.defaultProps = {
children: null, label: null,
onPress: () => {}, onPress: () => {},
}; };
Button.propTypes = { Button.propTypes = {
children: PropTypes.node, label: PropTypes.node,
onPress: PropTypes.func, onPress: PropTypes.func,
}; };

View File

@ -3,14 +3,14 @@ import PropTypes from 'prop-types';
import { View } from 'react-native'; import { View } from 'react-native';
import style from './style'; import style from './style';
export default function CenterView({ children }) { export default function CenterView({ label }) {
return <View style={style.main}>{children}</View>; return <View style={style.main}>{label}</View>;
} }
CenterView.defaultProps = { CenterView.defaultProps = {
children: null, label: null,
}; };
CenterView.propTypes = { CenterView.propTypes = {
children: PropTypes.node, label: PropTypes.node,
}; };

View File

@ -2,7 +2,7 @@
export const Button = (args) => { export const Button = (args) => {
const button = document.createElement('button'); const button = document.createElement('button');
button.innerHTML = args.children; button.innerHTML = args.label;
button.addEventListener('click', args.onClick); button.addEventListener('click', args.onClick);
return button; return button;

View File

@ -1,13 +1,13 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
export const Button = ({ onClick, children }) => ( export const Button = ({ onClick, label }) => (
<button type="button" onClick={onClick}> <button type="button" onClick={onClick}>
{children} {label}
</button> </button>
); );
Button.propTypes = { Button.propTypes = {
onClick: PropTypes.func.isRequired, onClick: PropTypes.func.isRequired,
children: PropTypes.node.isRequired, label: PropTypes.string.isRequired,
}; };

View File

@ -19,7 +19,7 @@
/** /**
* Button contents * Button contents
*/ */
export let children = ''; export let label = '';
let mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'; let mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
@ -41,5 +41,5 @@
{style} {style}
on:click={onClick} on:click={onClick}
> >
{children} {label}
</button> </button>

View File

@ -29,7 +29,7 @@
<h1>Button view</h1> <h1>Button view</h1>
<Button {primary} on:click on:click={handleClick} children="{text}: {count}" /> <Button {primary} on:click on:click={handleClick} label="{text}: {count}" />
<p>A little text to show this is a view.</p> <p>A little text to show this is a view.</p>
<p>If we need to test components in a Svelte environment, for instance to test slot behaviour,</p> <p>If we need to test components in a Svelte environment, for instance to test slot behaviour,</p>

View File

@ -1,5 +1,5 @@
<template> <template>
<button type="button" :class="classes" @click="onClick" :style="style">{{ children }}</button> <button type="button" :class="classes" @click="onClick" :style="style">{{ label }}</button>
</template> </template>
<script> <script>
@ -9,7 +9,7 @@ export default {
name: 'my-button', name: 'my-button',
props: { props: {
children: { label: {
type: String, type: String,
required: true, required: true,
}, },

View File

@ -3,4 +3,4 @@ export default {
component: {}, component: {},
}; };
export const StringOnly = () => '<global-button :primary="true" children="Primary button" />'; export const StringOnly = () => '<global-button :primary="true" label="Primary button" />';

View File

@ -29,7 +29,7 @@ export default {
}; };
export const Template = () => ({ export const Template = () => ({
template: '<global-button children="MyButton with template" />', template: '<global-button label="MyButton with template" />',
}); });
export const WithData = (_args, { parameters: { fileName, ...parameters }, hooks, ...rest }) => ({ export const WithData = (_args, { parameters: { fileName, ...parameters }, hooks, ...rest }) => ({
@ -38,6 +38,6 @@ export const WithData = (_args, { parameters: { fileName, ...parameters }, hooks
export const Render = () => ({ export const Render = () => ({
render(h) { render(h) {
return h(MyButton, { props: { color: 'pink', children: 'renders component: MyButton' } }); return h(MyButton, { props: { color: 'pink', label: 'renders component: MyButton' } });
}, },
}); });

View File

@ -12,7 +12,7 @@ export const Render = () => ({
export const RenderComponent = () => ({ export const RenderComponent = () => ({
render(h) { render(h) {
return h(MyButton, { props: { color: 'pink', children: 'renders component: MyButton' } }); return h(MyButton, { props: { color: 'pink', label: 'renders component: MyButton' } });
}, },
}); });
@ -26,7 +26,7 @@ export const Template = () => ({
export const TemplateComponent = () => ({ export const TemplateComponent = () => ({
components: { MyButton }, components: { MyButton },
template: '<my-button children="MyButton rendered in a template" />', template: '<my-button label="MyButton rendered in a template" />',
}); });
export const TemplateMethods = () => ({ export const TemplateMethods = () => ({
@ -34,7 +34,7 @@ export const TemplateMethods = () => ({
template: ` template: `
<p> <p>
<em>Clicking the button will navigate to another story using the 'addon-links'</em><br/> <em>Clicking the button will navigate to another story using the 'addon-links'</em><br/>
<my-button :rounded="true" @click="action" children="MyButton rendered in a template + props & methods" /> <my-button :rounded="true" @click="action" label="MyButton rendered in a template + props & methods" />
</p>`, </p>`,
methods: { methods: {
action: () => {}, action: () => {},
@ -46,7 +46,7 @@ export const TemplateMethods = () => ({
// components: { MyButton }, // components: { MyButton },
// render() { // render() {
// // eslint-disable-next-line react/react-in-jsx-scope, react/no-children-prop // // eslint-disable-next-line react/react-in-jsx-scope, react/no-children-prop
// return <my-button children="MyButton rendered with JSX" />; // return <my-button label="MyButton rendered with JSX" />;
// }, // },
// }); // });
@ -57,6 +57,6 @@ export const PreRegisteredComponent = () => ({
template: ` template: `
<p> <p>
<em>This component was pre-registered in .storybook/preview.js</em><br/> <em>This component was pre-registered in .storybook/preview.js</em><br/>
<global-button children="GlobalButton rendered in a template" /> <global-button label="GlobalButton rendered in a template" />
</p>`, </p>`,
}); });

View File

@ -19,7 +19,7 @@ export const Template = (args, { argTypes }) => ({
<Story name="Primary"> <Story name="Primary">
{{ {{
components: { MyButton: Button }, components: { MyButton: Button },
template: '<my-button :primary="true" children="Primary button" />', template: '<my-button :primary="true" label="Primary button" />',
}} }}
</Story> </Story>
</Canvas> </Canvas>
@ -30,7 +30,7 @@ export const Template = (args, { argTypes }) => ({
<Story name="Secondary"> <Story name="Secondary">
{{ {{
components: { MyButton: Button }, components: { MyButton: Button },
template: '<my-button :primary="false" children="Secondary button" />', template: '<my-button :primary="false" label="Secondary button" />',
}} }}
</Story> </Story>
</Canvas> </Canvas>
@ -38,7 +38,7 @@ export const Template = (args, { argTypes }) => ({
## From template ## From template
<Canvas> <Canvas>
<Story name="From Template" args={{ children: 'From template' }}> <Story name="From Template" args={{ label: 'From template' }}>
{Template.bind({})} {Template.bind({})}
</Story> </Story>
</Canvas> </Canvas>

View File

@ -1,5 +1,5 @@
<template> <template>
<button type="button" :class="classes" @click="onClick" :style="style">{{ children }}</button> <button type="button" :class="classes" @click="onClick" :style="style">{{ label }}</button>
</template> </template>
<script> <script>
@ -10,7 +10,7 @@ export default {
name: 'my-button', name: 'my-button',
props: { props: {
children: { label: {
type: String, type: String,
required: true, required: true,
}, },

View File

@ -18,12 +18,12 @@ export default {
export const Primary = { export const Primary = {
args: { args: {
primary: true, primary: true,
children: 'Globally Defined', label: 'Globally Defined',
}, },
}; };
export const Secondary = { export const Secondary = {
args: { args: {
children: 'Globally Defined', label: 'Globally Defined',
}, },
}; };

View File

@ -8,7 +8,7 @@ export default {
}; };
export const ComponentTemplate = { export const ComponentTemplate = {
args: { children: 'With component' }, args: { label: 'With component' },
decorators: [ decorators: [
() => ({ () => ({
components: { components: {
@ -23,7 +23,7 @@ export const ComponentTemplate = {
}; };
export const SimpleTemplate = { export const SimpleTemplate = {
args: { children: 'With border' }, args: { label: 'With border' },
decorators: [ decorators: [
() => ({ () => ({
template: ` template: `
@ -36,7 +36,7 @@ export const SimpleTemplate = {
}; };
export const VueWrapper = { export const VueWrapper = {
args: { children: 'With Vue wrapper' }, args: { label: 'With Vue wrapper' },
decorators: [ decorators: [
(storyFn) => { (storyFn) => {
// Call the `storyFn` to receive a component that Vue can render // Call the `storyFn` to receive a component that Vue can render
@ -50,7 +50,7 @@ export const VueWrapper = {
}; };
export const DynamicWrapper = { export const DynamicWrapper = {
args: { children: 'With dynamic wrapper', primary: true }, args: { label: 'With dynamic wrapper', primary: true },
argTypes: { argTypes: {
// Number type is detected, but we still want to constrain the range from 1-6 // Number type is detected, but we still want to constrain the range from 1-6
level: { control: { type: 'range', min: 1, max: 6 } }, level: { control: { type: 'range', min: 1, max: 6 } },

View File

@ -21,7 +21,7 @@ export const Template = (args, { argTypes }) => ({
<Story name="Primary"> <Story name="Primary">
{{ {{
components: { MyButton: Button }, components: { MyButton: Button },
template: '<my-button :primary="true" :children="Primary button" />', template: '<my-button :primary="true" :label="Primary button" />',
}} }}
</Story> </Story>
</Canvas> </Canvas>
@ -32,7 +32,7 @@ export const Template = (args, { argTypes }) => ({
<Story name="Secondary"> <Story name="Secondary">
{{ {{
components: { MyButton: Button }, components: { MyButton: Button },
template: '<my-button :primary="false" :children="Secondary button" />', template: '<my-button :primary="false" :label="Secondary button" />',
}} }}
</Story> </Story>
</Canvas> </Canvas>
@ -40,7 +40,7 @@ export const Template = (args, { argTypes }) => ({
## From template ## From template
<Canvas> <Canvas>
<Story name="From Template" args={{ children: 'From template' }}> <Story name="From Template" args={{ label: 'From template' }}>
{Template.bind({})} {Template.bind({})}
</Story> </Story>
</Canvas> </Canvas>

View File

@ -5,7 +5,7 @@ import { html, LitElement } from 'lit';
const { CustomEvent, customElements } = globalThis; const { CustomEvent, customElements } = globalThis;
/** /**
* @attr {string} children - Children of the button * @attr {string} label - Label of the button
* @attr {string} size - Size of the button, can be "small", "medium" or "large"; default is "medium". * @attr {string} size - Size of the button, can be "small", "medium" or "large"; default is "medium".
* @attr {string} backgroundColor - Color of the button's background * @attr {string} backgroundColor - Color of the button's background
* *
@ -24,7 +24,7 @@ export class SbButton extends LitElement {
// https://github.com/Polymer/lit-html/issues/1476 // https://github.com/Polymer/lit-html/issues/1476
static get properties() { static get properties() {
return { return {
children: { type: String, reflect: true }, label: { type: String, reflect: true },
primary: { type: Boolean }, primary: { type: Boolean },
size: { type: String }, size: { type: String },
backgroundColor: { type: String, attribute: 'background-color' }, backgroundColor: { type: String, attribute: 'background-color' },
@ -36,7 +36,7 @@ export class SbButton extends LitElement {
this.primary = undefined; this.primary = undefined;
this.backgroundColor = undefined; this.backgroundColor = undefined;
this.size = 'medium'; this.size = 'medium';
this.children = ''; this.label = '';
} }
onClick() { onClick() {
@ -56,7 +56,7 @@ export class SbButton extends LitElement {
class=${['storybook-button', `storybook-button--${this.size ?? 'medium'}`, mode].join(' ')} class=${['storybook-button', `storybook-button--${this.size ?? 'medium'}`, mode].join(' ')}
@click="${this.onClick}" @click="${this.onClick}"
> >
${this.children} ${this.label}
</button> </button>
`; `;
} }