Skip to content

Commit

Permalink
feat(button): add inverted (#649)
Browse files Browse the repository at this point in the history
* feat(button): add inverted

* feat(button): update default inverted colors

* feat(toast-plate): remove inverted mixin, use prop

* chore: update snapshots

* feat: remove inverted themes

* fix(button): inverted loading

* feat(button): update screenshots

* feat(icon-button): add inverted props, remove themes (#658)

* feat(link): add inverted props, remove themes (#657)

* feat: inverted -> colors=inverted

* fix(button): update screenshot

BREAKING CHANGE: remove inverted themes
  • Loading branch information
reme3d2y committed May 25, 2021
1 parent 7c480a2 commit be321b0
Show file tree
Hide file tree
Showing 133 changed files with 1,576 additions and 1,004 deletions.
17 changes: 1 addition & 16 deletions .storybook/addons/theme-switcher/index.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
@import '../../../packages/themes/src/mixins/default-inverted.css';
@import '../../../packages/themes/src/mixins/click.css';
@import '../../../packages/themes/src/mixins/site.css';
@import '../../../packages/themes/src/mixins/site-inverted.css';
@import '../../../packages/themes/src/mixins/corp.css';
@import '../../../packages/themes/src/mixins/corp-inverted.css';
@import '../../../packages/themes/src/mixins/mobile.css';

.tool {
Expand All @@ -13,14 +10,10 @@

.label {
display: inline-block;
margin-right: 8px;
margin-right: var(--gap-xs);
font-size: 13px;
}

[data-theme='default-inverted'] {
@mixin theme-default-inverted;
}

[data-theme='click'] {
@mixin theme-click;
}
Expand All @@ -29,18 +22,10 @@
@mixin theme-site;
}

[data-theme='site-inverted'] {
@mixin theme-site-inverted;
}

[data-theme='corp'] {
@mixin theme-corp;
}

[data-theme='corp-inverted'] {
@mixin theme-corp-inverted;
}

[data-theme='mobile'] {
@mixin theme-mobile;
}
2 changes: 1 addition & 1 deletion packages/attach/src/__snapshots__/Component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`Attach Snapshots tests should match snapshot 1`] = `
class="component s"
>
<button
class="component outlined s"
class="component outlined s component outlined"
type="button"
>
<span
Expand Down
3 changes: 1 addition & 2 deletions packages/button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"react-merge-refs": "^1.1.0"
},
"buildThemes": [
"site",
"site-inverted"
"site"
]
}
16 changes: 16 additions & 0 deletions packages/button/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ import { useFocus } from '@alfalab/hooks';
import { Loader } from '@alfalab/core-components-loader';

import styles from './index.module.css';
import defaultColors from './default.module.css';
import invertedColors from './inverted.module.css';

const colorStyles = {
default: defaultColors,
inverted: invertedColors,
};

export type ComponentProps = {
/**
Expand Down Expand Up @@ -63,6 +70,11 @@ export type ComponentProps = {
* Не переносить текст кнопки на новую строку
*/
nowrap?: boolean;

/**
* Набор цветов для компонента
*/
colors?: 'default' | 'inverted';
};

type AnchorButtonProps = ComponentProps & AnchorHTMLAttributes<HTMLAnchorElement>;
Expand Down Expand Up @@ -90,6 +102,7 @@ export const Button = React.forwardRef<HTMLAnchorElement | HTMLButtonElement, Bu
href,
loading = false,
nowrap = false,
colors = 'default',
...restProps
},
ref,
Expand All @@ -109,12 +122,15 @@ export const Button = React.forwardRef<HTMLAnchorElement | HTMLButtonElement, Bu
styles.component,
styles[view],
styles[size],
colorStyles[colors].component,
colorStyles[colors][view],
{
[styles.focused]: focused,
[styles.block]: block,
[styles.iconOnly]: !children,
[styles.nowrap]: nowrap,
[styles.loading]: showLoader,
[colorStyles[colors].loading]: showLoader,
},
className,
),
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
28 changes: 14 additions & 14 deletions packages/button/src/__snapshots__/Component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Object {
"baseElement": <body>
<div>
<button
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
type="button"
/>
</div>
</body>,
"container": <div>
<button
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
type="button"
/>
</div>,
Expand Down Expand Up @@ -77,14 +77,14 @@ Object {
"baseElement": <body>
<div>
<a
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
href="https://some-url"
/>
</div>
</body>,
"container": <div>
<a
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
href="https://some-url"
/>
</div>,
Expand Down Expand Up @@ -148,14 +148,14 @@ Object {
"baseElement": <body>
<div>
<button
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
type="button"
/>
</div>
</body>,
"container": <div>
<button
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
type="button"
/>
</div>,
Expand Down Expand Up @@ -219,7 +219,7 @@ Object {
"baseElement": <body>
<div>
<button
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
type="button"
>
<span
Expand All @@ -234,7 +234,7 @@ Object {
</body>,
"container": <div>
<button
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
type="button"
>
<span
Expand Down Expand Up @@ -306,7 +306,7 @@ Object {
"baseElement": <body>
<div>
<a
class="component secondary m iconOnly loading"
class="component secondary m component secondary iconOnly loading"
href="https://some-url"
>
<svg
Expand Down Expand Up @@ -336,7 +336,7 @@ Object {
</body>,
"container": <div>
<a
class="component secondary m iconOnly loading"
class="component secondary m component secondary iconOnly loading"
href="https://some-url"
>
<svg
Expand Down Expand Up @@ -423,7 +423,7 @@ Object {
"baseElement": <body>
<div>
<button
class="component secondary m iconOnly loading"
class="component secondary m component secondary iconOnly loading"
disabled=""
type="button"
>
Expand Down Expand Up @@ -454,7 +454,7 @@ Object {
</body>,
"container": <div>
<button
class="component secondary m iconOnly loading"
class="component secondary m component secondary iconOnly loading"
disabled=""
type="button"
>
Expand Down Expand Up @@ -542,7 +542,7 @@ Object {
"baseElement": <body>
<div>
<button
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
type="button"
>
<span
Expand All @@ -557,7 +557,7 @@ Object {
</body>,
"container": <div>
<button
class="component secondary m iconOnly"
class="component secondary m component secondary iconOnly"
type="button"
>
<span
Expand Down

0 comments on commit be321b0

Please sign in to comment.