Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
feat: implement box-model and rewrite ButtonIcon
Browse files Browse the repository at this point in the history
  • Loading branch information
tatinacher committed May 6, 2021
1 parent bc37f0f commit a6a115d
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/static/icons/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/static/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export { default as ArrowLeft } from './arrow-left.svg';
export { default as Check } from './check.svg';
export { default as CheckIcon } from './icon_check.svg';
export { default as ClosedEyeIcon } from './closed-eye.svg';
export { default as CloseIcon } from './close-small.svg';
export { default as CloseIcon } from './close.svg';
export { default as InfoIcon } from './info.svg';
export { default as MoreIcon } from './more.svg';
export { default as OpenedEyeIcon } from './opened-eye.svg';
Expand Down
4 changes: 2 additions & 2 deletions src/static/icons/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 23 additions & 8 deletions src/ui/atoms/button-icon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import styled, { StyledComponent } from 'styled-components';
import { Variant } from 'lib/types';
import { box } from 'ui/elements/quarks';

interface Props extends React.ButtonHTMLAttributes<HTMLButtonElement> {
className?: string;
Expand All @@ -22,24 +23,38 @@ const ButtonIconBase: React.FC<Props & Variant> = ({
);

export const ButtonIcon = styled(ButtonIconBase)`
${box}
--local-vertical: calc(
1px * var(--woly-component-level) * var(--woly-main-level)
);
--local-shape-color: var(--woly-canvas-default);
--local-icon-size: var(--woly-line-height);
--local-icon-color: var(--woly-canvas-text-default);
--local-padding: calc(1px * var(--woly-component-level) * var(--woly-main-level));
--local-icon-size: calc(var(--woly-line-height));
--local-button-size: calc(var(--local-icon-size) + (var(--local-vertical) * 2));
--local-icon-color: var(--woly-shape-default);
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
border: var(--woly-border) solid var(--local-shape-color);
border-radius: var(--woly-rounding, 4px);
width: var(--local-button-size);
height: var(--local-button-size);
border: var(--woly-border-width) solid var(--local-shape-color);
border-radius: var(--woly-rounding);
cursor: pointer;
padding: var(--local-padding);
background: var(--local-shape-color);
outline: none;
[data-icon] {
display: flex;
align-items: center;
justify-content: center;
width: var(--local-icon-size);
height: var(--local-icon-size);
svg {
width: var(--local-icon-size);
height: var(--local-icon-size);
}
svg > path {
fill: var(--local-icon-color);
Expand Down
34 changes: 34 additions & 0 deletions src/ui/elements/quarks/box/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { css } from 'styled-components';

export const box = css`
--local-vertical: calc(1px * var(--woly-component-level) * var(--woly-main-level));
--local-horizontal: calc(
var(--woly-const-m) + (1px * var(--woly-main-level)) + var(--local-vertical)
);
--local-gap: var(--local-vertical);
--local-compensate: var(--local-vertical);
& > * {
padding-top: var(--local-vertical);
padding-bottom: var(--local-vertical);
}
& > :first-child {
padding-left: var(--local-horizontal);
}
& > :last-child {
padding-right: var(--local-horizontal);
}
& > [data-icon]:first-child {
padding-left: var(--local-compensate);
}
& > [data-icon]:last-child {
padding-right: var(--local-compensate);
}
& > :not(:first-child) {
margin-left: var(--local-gap);
}
`;
1 change: 1 addition & 0 deletions src/ui/elements/quarks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { box } from './box';
export { InputContainer } from './input-container';
export { InputElement } from './input-element';

0 comments on commit a6a115d

Please sign in to comment.