Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for button component #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions web-components/src/components/button/button.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { html, unsafeCSS } from 'lit';
import { html, TemplateResult, unsafeCSS } from 'lit';
import { customElement, property, query } from 'lit/decorators.js';
import styles from './button.css?inline';
import BaseElement from '../../internals/baseElement/baseElement';
import { TemplateResult } from 'lit-html';
import { ifDefined } from 'lit-html/directives/if-defined.js';
import { ifDefined } from 'lit/directives/if-defined.js';
import { ElementInternals } from 'element-internals-polyfill/dist/element-internals';
import { when } from 'lit-html/directives/when.js';
import { when } from 'lit/directives/when.js';
import '../tooltip/tooltip.component';
import '../spinner/spinner.component';
import { SpinnerType } from '../spinner/spinner.component';
Expand All @@ -21,6 +20,7 @@ export const buttonSpacings = [
'text',
'icon',
'icon-only',
'none'
] as const;
export type ButtonSpacing = typeof buttonSpacings[number];

Expand Down Expand Up @@ -97,8 +97,8 @@ export default class Button extends BaseElement {
<button
slot="${ifDefined(slotName)}"
part="button"
class=${`type-${this.type} spacing-${this.buttonSpacing} remove-radius-${this.removeRadius} remove-border-${this.removeBorder}`}
?disabled=${this.disabled}
class="${`type-${this.type} spacing-${this.buttonSpacing} remove-radius-${this.removeRadius} remove-border-${this.removeBorder}`}"
?disabled="${this.disabled}"
>
<slot @click="${this.handleClickEvent}"></slot>
${when(this.loading, () => html`
Expand All @@ -123,7 +123,7 @@ export default class Button extends BaseElement {
}

private get buttonSpacing(): ButtonSpacing {
if (this.type === 'icon-only') {
if (this.type === 'icon-only' && this.spacing === 'text') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I understand this change. What's the use case for type 'icon-only' but spacing 'text'?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't fully remember, it's a change we did in the project (last October 😉). As far as I understand it, the type "icon-only" should only affect spacing if that has not been set explicitly, which would mean something else than "text" as that's the default.

return 'icon-only';
}

Expand Down
4 changes: 4 additions & 0 deletions web-components/src/components/button/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ button:not(:disabled):focus-visible {
padding: var(--size-0-25);
}

.spacing-none {
padding: 0;
}

.remove-border-left,
.remove-radius-left {
border-bottom-left-radius: 0;
Expand Down
36 changes: 29 additions & 7 deletions web-components/src/components/button/button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { html } from 'lit-html';
import { Meta, StoryFn, StoryObj, WebComponentsRenderer } from '@storybook/web-components';
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
import docs from './button.md?raw';
import { ifDefined } from 'lit-html/directives/if-defined.js';
import ellipsisDocs from './ellipsis.md?raw';
import { ifDefined } from 'lit/directives/if-defined.js';
import { withActions } from '@storybook/addon-actions/decorator';

const meta: Meta<Button> = {
Expand Down Expand Up @@ -41,13 +42,18 @@ const Template: StoryFn<Button> = ({
tooltip,
loading,
}) => html`
<style>
dss-button {
max-width: 100%;
}
</style>
<dss-button
type=${ifDefined(type)}
spacing=${ifDefined(spacing)}
removeRadius=${ifDefined(removeRadius)}
removeBorder=${ifDefined(removeBorder)}
tooltip=${ifDefined(tooltip)}
?disabled=${disabled}
type="${ifDefined(type)}"
spacing="${ifDefined(spacing)}"
removeRadius="${ifDefined(removeRadius)}"
removeBorder="${ifDefined(removeBorder)}"
tooltip="${ifDefined(tooltip)}"
?disabled="${disabled}"
?loading="${loading}"
>
${unsafeHTML(slot)}
Expand Down Expand Up @@ -146,3 +152,19 @@ export const LoadingButton: StoryObj<Button> = {
slot: 'Loading',
},
};

export const WithEllipsis = Template.bind({});
WithEllipsis.parameters = {
docs: {
description: {
story: ellipsisDocs,
},
},
};
WithEllipsis.args = {
slot: `
<span style="min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</span>
`,
};