Skip to content

Commit d264e73

Browse files
authored
fix: fixed padding and added multiline story (#277)
* fixed padding and added multiline story * type-checking on button story
1 parent 6b1ee6f commit d264e73

File tree

2 files changed

+94
-9
lines changed

2 files changed

+94
-9
lines changed

packages/uui-button/lib/uui-button.element.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export class UUIButtonElement extends FormControlMixin(
5151
margin-left: calc(var(--uui-button-merge-border-left, 0) * -1px);
5252
--uui-button-padding-left-factor: 3;
5353
--uui-button-padding-right-factor: 3;
54+
--uui-button-padding-top-factor: 1;
55+
--uui-button-padding-bottom-factor: 1;
5456
5557
min-height: var(--uui-button-height, var(--uui-size-11));
5658
max-height: 100%;
@@ -65,6 +67,8 @@ export class UUIButtonElement extends FormControlMixin(
6567
:host([compact]) {
6668
--uui-button-padding-left-factor: 1;
6769
--uui-button-padding-right-factor: 1;
70+
--uui-button-padding-top-factor: 0;
71+
--uui-button-padding-bottom-factor: 0;
6872
}
6973
7074
.label {
@@ -117,8 +121,9 @@ export class UUIButtonElement extends FormControlMixin(
117121
);
118122
cursor: pointer;
119123
120-
padding: 0
121-
calc(var(--uui-size-2) * var(--uui-button-padding-right-factor)) 0
124+
padding: calc(var(--uui-size-2) * var(--uui-button-padding-top-factor))
125+
calc(var(--uui-size-2) * var(--uui-button-padding-right-factor))
126+
calc(var(--uui-size-2) * var(--uui-button-padding-bottom-factor))
122127
calc(var(--uui-size-2) * var(--uui-button-padding-left-factor));
123128
124129
box-shadow: none;

packages/uui-button/lib/uui-button.story.ts

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import '.';
22
import '@umbraco-ui/uui-badge/lib';
33
import '@umbraco-ui/uui-icon/lib';
44

5-
import { Story } from '@storybook/web-components';
5+
import { Meta, Story } from '@storybook/web-components';
66
import { html } from 'lit-html';
7+
import { UUIButtonElement } from './uui-button.element';
78

89
export default {
910
title: 'Buttons/Button',
@@ -15,9 +16,9 @@ export default {
1516
target: undefined,
1617
look: 'default',
1718
color: 'default',
18-
type: '',
19+
type: undefined,
1920
label: 'Button',
20-
state: '',
21+
state: undefined,
2122
},
2223
argTypes: {
2324
look: {
@@ -54,7 +55,7 @@ export default {
5455
'--uui-button-background-color-disabled': { control: { type: 'color' } },
5556
'--uui-button-contrast-disabled': { control: { type: 'color' } },
5657
},
57-
};
58+
} as Meta<UUIButtonElement>;
5859

5960
const cssProps = [
6061
'--uui-button-height',
@@ -87,12 +88,12 @@ const Template: Story = props => {
8788
.reduce(reducer)}
8889
?disabled=${props.disabled}
8990
?compact=${props.compact}
91+
.state=${props.state}
92+
.href=${props.href}
93+
.target=${props.target}
9094
look=${props.look}
9195
color=${props.color}
9296
label=${props.label}
93-
state=${props.state}
94-
href=${props.href}
95-
target=${props.target}
9697
>${props.content}</uui-button
9798
>
9899
`;
@@ -340,3 +341,82 @@ AnchorTag.parameters = {
340341
},
341342
},
342343
};
344+
345+
export const MultiLine: Story = props => {
346+
return html`
347+
<uui-button
348+
type=${props.type}
349+
style=${cssProps
350+
.map(cssProp => (props[cssProp] ? `${cssProp}: ${props[cssProp]}` : ''))
351+
.reduce(reducer)}
352+
?disabled=${props.disabled}
353+
?compact=${props.compact}
354+
look=${props.look}
355+
color=${props.color}
356+
label=${props.label}
357+
state=${props.state}
358+
href=${props.href}
359+
target=${props.target}
360+
>Hello <br />
361+
I am button</uui-button
362+
>
363+
<br /><br />
364+
<uui-button
365+
type=${props.type}
366+
style=${cssProps
367+
.map(cssProp => (props[cssProp] ? `${cssProp}: ${props[cssProp]}` : ''))
368+
.reduce(reducer)}
369+
?disabled=${props.disabled}
370+
?compact=${props.compact}
371+
look=${props.look}
372+
color=${props.color}
373+
label=${props.label}
374+
state=${props.state}
375+
href=${props.href}
376+
target=${props.target}>
377+
<uui-badge color="danger">2</uui-badge>
378+
Hello <br />
379+
I am button
380+
</uui-button>
381+
<br /><br />
382+
<uui-button
383+
type=${props.type}
384+
style=${cssProps
385+
.map(cssProp => (props[cssProp] ? `${cssProp}: ${props[cssProp]}` : ''))
386+
.reduce(reducer)}
387+
?disabled=${props.disabled}
388+
compact
389+
look=${props.look}
390+
color=${props.color}
391+
label=${props.label}
392+
state=${props.state}
393+
href=${props.href}
394+
target=${props.target}>
395+
Hi <br />
396+
I am compact
397+
</uui-button>
398+
<br /><br />
399+
<uui-icon-registry-essential>
400+
<uui-button
401+
type=${props.type}
402+
style=${cssProps
403+
.map(cssProp =>
404+
props[cssProp] ? `${cssProp}: ${props[cssProp]}` : ''
405+
)
406+
.reduce(reducer)}
407+
?disabled=${props.disabled}
408+
?compact=${props.compact}
409+
look=${props.look}
410+
color=${props.color}
411+
label=${props.label}
412+
state=${props.state}
413+
href=${props.href}
414+
target=${props.target}>
415+
<uui-icon .name=${'favorite'}></uui-icon>
416+
<br />Home
417+
</uui-button>
418+
</uui-icon-registry-essential>
419+
`;
420+
};
421+
422+
MultiLine.args = { look: 'primary' };

0 commit comments

Comments
 (0)