Skip to content

Commit

Permalink
Merge pull request #89 from emulsify-ds/feat-spacing-component
Browse files Browse the repository at this point in the history
feat: add spacing component
  • Loading branch information
mcortes19 committed Sep 22, 2023
2 parents febcde2 + d52b51a commit 5dd19b6
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
19 changes: 19 additions & 0 deletions components/00-base/04-spacing/_spacing.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.spacing {
td:not(:last-child) {
width: 14rem;
}
}

.spacing-visualization__wrapper {
display: inline-flex;
flex-flow: row nowrap;
}

.spacing-visualization {
width: 3rem;
height: 3rem;
display: block;
border-radius: 4px;
background-color: clr(text);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}
8 changes: 8 additions & 0 deletions components/00-base/04-spacing/spacing.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import spacingTwig from './spacing.twig';
import spacingData from './spacing.yml';

export default {
title: 'Base/Spacing',
};

export const Spacing = () => spacingTwig(spacingData);
38 changes: 38 additions & 0 deletions components/00-base/04-spacing/spacing.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% set table__base_class = 'table' %}
{% set spacing__base_class = 'spacing' %}

<div {{ bem(spacing__base_class) }}>
{% for spacing in spacing_list %}
{% include "@atoms/text/headings/_heading.twig" with {
heading_level: 1,
heading: spacing.name,
heading_base_class: spacing__base_class,
} %}
<table {{ bem(table__base_class) }}>
<thead {{ bem('header', [], table__base_class) }}>
<tr>
<th {{ bem('header_cell', [], table__base_class) }}>Token name</th>
<th {{ bem('header_cell', [], table__base_class) }}>REM</th>
<th {{ bem('header_cell', [], table__base_class) }}>PX</th>
<th {{ bem('header_cell', [], table__base_class) }}>Example</th>
</tr>
</thead>
<tbody>
{% for space in spacing.items %}
<tr {{ bem('row', [], table__base_class) }}>
<td {{ bem('cell', [], table__base_class) }}>{{ space.name}}</td>
<td {{ bem('cell', [], table__base_class) }}>{{ space.rem }}</td>
<td {{ bem('cell', [], table__base_class) }}>{{ space.px }}</td>
<td {{ bem('cell', [], table__base_class) }}>
<span class="spacing-visualization__wrapper" style="gap: {{space.px}}">
<span class="spacing-visualization"></span>
<span class="spacing-visualization"></span>
<span class="spacing-visualization"></span>
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
</div>
50 changes: 50 additions & 0 deletions components/00-base/04-spacing/spacing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
spacing_heading: Spacing
spacing_list:
- name: Spacing
items:
- name: $space
rem: 1rem
px: 16px
- name: Times
items:
- name: $space-double
rem: 2rem
px: 32px
- name: $space-triple
rem: 3rem
px: 48px
- name: $space-quadruple
rem: 4rem
px: 64px
- name: $space-quintuple
rem: 5rem
px: 80px
- name: $space-sextuple
rem: 6rem
px: 96px
- name: $space-septuple
rem: 7rem
px: 112px
- name: Divided
items:
- name: $space-one-half
rem: 0.5rem
px: 8px
- name: $space-one-third
rem: 0.33rem
px: 5.33px
- name: $space-one-fourth
rem: 0.25rem
px: 4px
- name: $space-one-fifth
rem: 0.2rem
px: 3.2px
- name: $space-one-sixth
rem: 0.16rem
px: 2.66px
- name: $space-one-seventh
rem: 0.14rem
px: 2.28px
- name: $space-one-eighth
rem: 0.12rem
px: 2px

0 comments on commit 5dd19b6

Please sign in to comment.