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

feat: button component #118

Merged
merged 26 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift click to select a range
efa8888
feat: button component
leventozen May 22, 2022
5e4f115
feat: button component
leventozen May 29, 2022
8e68bbe
chore: added missing stories to button component
leventozen Jun 3, 2022
4893c82
refactor: added css improvements, delete unnecessary tokens from theme
leventozen Jun 5, 2022
158e211
Merge branch 'next' of https://github.com/Trendyol/grace into 85-butt…
leventozen Jun 5, 2022
d5c7ead
fix: lint css
leventozen Jun 5, 2022
43c863a
fix(button): change: grace element to baklava at button
leventozen Jun 6, 2022
043d43b
fix: border sizing issue at button component
leventozen Jun 8, 2022
de6ad36
refactor(button): add new shared variables to button component to mak…
leventozen Jun 8, 2022
ecb00bc
fix(design): lint design tokens
leventozen Jun 8, 2022
75a3a01
refactor(input): style optimizations
muratcorlu Jun 8, 2022
3d53e65
fix(button): style fixes for button variants
muratcorlu Jun 8, 2022
68ea9ac
refactor(button): css lint
muratcorlu Jun 8, 2022
300a8f9
feat(button): breaking very long texts in button
muratcorlu Jun 9, 2022
a8a93a6
fix(icon): icon crop issue fixed
muratcorlu Jun 9, 2022
ee9d45a
fix(button): outline disabled hover state fixed
muratcorlu Jun 9, 2022
a676176
fix(button): font sizing problems fixed
muratcorlu Jun 9, 2022
47dcc5b
fix(button): error variant renamed as danger
muratcorlu Jun 9, 2022
499f09f
fix(button): prettier fine tune
muratcorlu Jun 9, 2022
51b83e3
feat(button): setting icon as attribute
muratcorlu Jun 9, 2022
73fd1d6
refactor: lint fixes
muratcorlu Jun 9, 2022
913d997
docs(design): some typography and color rules documented
muratcorlu Jun 9, 2022
82aed98
docs(button): storybook stories simplified
muratcorlu Jun 10, 2022
20780d1
feat(button): link buttons renamed as plain buttons
muratcorlu Jun 10, 2022
e19b4c3
docs(button): button docs improved
muratcorlu Jun 10, 2022
679c20f
refactor(button): some optimizations
muratcorlu Jun 10, 2022
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
Prev Previous commit
Next Next commit
feat(button): link buttons renamed as plain buttons
  • Loading branch information
muratcorlu committed Jun 10, 2022
commit 20780d1b3881b7abd88f9cf915bbc182aa2d8eba
1 change: 0 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,5 1,4 @@
module.exports = {
logLevel: 'debug',
stories: ['../*.md', '../docs/**/*.stories.mdx', '../src/**/*.stories.mdx'],
addons: [
'@storybook/addon-links',
Expand Down
6 changes: 3 additions & 3 deletions src/components/button/bl-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 89,13 @@
--bl-button-main-hover-color: var(--bl-color-danger-hover);
}

:host([link]) {
:host([plain]) {
--bl-button-content-color: var(--bl-button-main-color);
--bl-button-border-color: transparent;
--bl-button-bg-color: transparent;
}

:host([link]) .button {
:host([plain]) .button {
text-decoration: underline;
}

Expand All @@ -120,7 120,7 @@
--bl-button-content-color: var(--bl-button-main-color);
}

:host([link]:not([disabled])) .button:hover {
:host([plain]:not([disabled])) .button:hover {
--bl-button-content-color: var(--bl-button-main-hover-color);
--bl-button-border-color: transparent;
--bl-button-bg-color: transparent;
Expand Down
36 changes: 21 additions & 15 deletions src/components/button/bl-button.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 26,7 @@ import { Meta, Canvas, ArgsTable, Story, Preview, Source } from '@storybook/addo
disabled: {
control: 'boolean'
},
link: {
plain: {
control: {
type: 'boolean'
}
Expand Down Expand Up @@ -55,13 55,13 @@ export const BasicTemplate = (args) => html`<bl-button
?danger=${args.danger}
?outline=${args.outline}
?disabled=${args.disabled}
?link=${args.link}
?plain=${args.plain}
href=${ifDefined(args.href)}
target=${ifDefined(args.target)}
size=${ifDefined(args.size)}
icon="${ifDefined(args.icon)}"
label="${ifDefined(args.label)}"
>${args.text}</bl-button>`
>${args.content}</bl-button>`

export const Template = (args) => html`
${BasicTemplate({primary: true, ...args})}
Expand All @@ -78,17 78,20 @@ ${BasicTemplate({size: 'large', ...args})}`;
export const VariousStylesTemplate = (args) => html`
${BasicTemplate({...args})}
${BasicTemplate({outline: true, ...args})}
${BasicTemplate({link: true, ...args})}`;
${BasicTemplate({plain: true, ...args})}`;

# Button

Button component is the component for triggering actions.

In Baklava Design, we provide 2 types of button:
In Baklava Design, we provide 3 types of button:

* Contained Button (Default)
* Outline Button
* Text Button
* Link Button

We have 4 variants of each button:

* `primary`
* `secondary`
* `success`
Expand All @@ -99,7 102,7 @@ We have 4 variants of each button:
Primary button is used for main actions of the screens. Like a submit button in a form or main button of a dialog.

<Canvas>
<Story name="Variants" args={{ text: 'Save' }}>
<Story name="Variants" args={{ content: 'Save' }}>
{Template.bind({})}
</Story>
</Canvas>
Expand All @@ -108,7 111,7 @@ Primary button is used for main actions of the screens. Like a submit button in
Outlined Buttons represent the important actions in the app. But not the primary ones.
They work with all the variants. You simply add `outline` attribute.
<Canvas>
<Story name="Outline Buttons" args={{ outline: true, text: 'Save' }}>
<Story name="Outline Buttons" args={{ outline: true, content: 'Save' }}>
{Template.bind({})}
</Story>
</Canvas>
Expand All @@ -120,31 123,34 @@ Our icons are defined to be `left` of the default slot.
To be able to use icon with button, you should give the name of icon to `icon` attribute.

<Canvas>
<Story name="Outline Icon Buttons" args={{ outline: true, text: 'Save', icon: 'info' }}>
<Story name="Outline Icon Buttons" args={{ outline: true, content: 'Save', icon: 'info' }}>
{Template.bind({})}
</Story>
</Canvas>


## Icon Only Buttons

Icon Only Buttons commonly used for toggle actions. (Ex.: add item to your favorites.)

<Canvas>
<Story name="Outline Icon Only Buttons" args={{ label: 'Save', icon: 'info' }}>
{Template.bind({})}
</Story>
</Canvas>

## Link Buttons
## Plain Buttons

<Canvas>
<Story name="Link Buttons" args={{ href: "https://trendyol.com", link: true, text: 'Save' }}>
<Story name="Text Buttons" args={{ href: "https://trendyol.com", plain: true, content: 'Save' }}>
{Template.bind({})}
</Story>
</Canvas>

## Link Buttons With Icon
## Plain Buttons With Icon

<Canvas>
<Story name="Link Buttons With Icon" args={{ link: true, href: "https://trendyol.com", text: 'Save', icon: 'info' }}>
<Story name="Text Buttons With Icon" args={{ plain: true, href: "https://trendyol.com", content: 'Save', icon: 'info' }}>
{Template.bind({})}
</Story>
</Canvas>
Expand All @@ -154,7 160,7 @@ Icon Only Buttons commonly used for toggle actions. (Ex.: add item to your favor
We have 3 sizes of buttons: `large`, `medium`, `small`. Default size is `medium`.

<Canvas>
<Story name="Button Sizes" args={{ text: 'Confirm', icon: 'info' }}>
<Story name="Button Sizes" args={{ content: 'Confirm', icon: 'info' }}>
{SizesTemplate.bind({})}
</Story>
</Canvas>
Expand All @@ -164,7 170,7 @@ We have 3 sizes of buttons: `large`, `medium`, `small`. Default size is `medium`
By default buttons use size as its content needs.

<Canvas columns={1}>
<Story name="Secondary disabled button" args={{ disabled: true, icon: 'info', text: 'Fill the form' }}>
<Story name="Secondary disabled button" args={{ disabled: true, icon: 'info', content: 'Fill the form' }}>
{VariousStylesTemplate.bind({})}
</Story>
</Canvas>
Expand Down
5 changes: 4 additions & 1 deletion src/components/button/bl-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 18,7 @@ export type TargetType = '_blank' | '_parent' | '_self' | '_top';
* @property {boolean} danger - Sets variant to danger
* @property {boolean} outline - Sets button version to outline
* @property {boolean} disabled - Disables the button
* @property {boolean} link - Sets the button text style
* @property {boolean} plain - Sets the button plain text style
* @property {string} size - Sets the button size
* @property {string} icon - Sets the name of the icon
* @property {string} href - Sets link of the button
Expand Down Expand Up @@ -51,6 51,9 @@ export default class BlButton extends LitElement {
@property({ type: Boolean, reflect: true })
outline = false;

@property({ type: Boolean, reflect: true })
plain = false;

@property({ type: String, reflect: true })
size: ButtonSize = 'medium';

Expand Down