Skip to content

Commit a3f82c0

Browse files
Add a Draft Email prototype (#2109)
1 parent b8f4feb commit a3f82c0

File tree

10 files changed

+644
-11
lines changed

10 files changed

+644
-11
lines changed

.changeset/sharp-lemons-hunt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Added easeInOutSine and easeOutSine ease tokens

.changeset/wild-cougars-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Updated Button component to support `id` attribute

src/components/button/button.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
<{{ tag_name }}
1717
class="c-button{% if class %} {{ class }}{% endif %}"
18+
{% if id %}
19+
id="{{ id }}"
20+
{% endif %}
1821
{% if aria_disabled %}
1922
aria-disabled="{{ aria_disabled }}"
2023
{% endif %}

src/mixins/_button.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
@mixin content {
168168
/// We use opacity because it will not paint but it also won't remove the
169169
/// element's keyboard events (if any).
170-
/// @link https: //stackoverflow.com/a/34529598
170+
/// @link https://stackoverflow.com/a/34529598
171171
.is-loading & {
172172
opacity: 0;
173173
}
Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
@use '../../compiled/tokens/scss/size';
22

3-
/**
4-
* Button Group layout object
5-
* 1. Margins are used instead of Flexbox Gap due to browser support (consider
6-
* changing to Flexbox Gap once browser support is better in the future).
7-
*/
3+
///
4+
/// Button Group layout object
5+
///
6+
/// 1. Margins are used instead of Flexbox Gap due to browser support (consider
7+
/// changing to Flexbox Gap once browser support is better in the future).
8+
89
.o-button-group {
910
--gap: #{size.$spacing-gap-button-group-default};
1011

@@ -17,9 +18,23 @@
1718
}
1819
}
1920

20-
/**
21-
* Full button width modifier
22-
*/
23-
.o-button-group--grow > * {
24-
flex: 1 1 0;
21+
///
22+
/// For use cases when a button has sibling elements, they can all be wrapped
23+
/// with an "item" element to maintain proper layout
24+
///
25+
26+
.o-button-group__item {
27+
display: flex;
28+
position: relative;
29+
}
30+
31+
///
32+
/// Full button-width modifier
33+
///
34+
35+
.o-button-group--grow {
36+
> *,
37+
.o-button-group__item > * {
38+
flex: 1 1 0;
39+
}
2540
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
@use '../../../compiled/tokens/scss/size';
2+
@use '../../../compiled/tokens/scss/color';
3+
@use '../../../compiled/tokens/scss/ease';
4+
@use '../../../compiled/tokens/scss/transition';
5+
@use '../../../compiled/tokens/scss/z-index';
6+
@use 'sass:color' as sass-color;
7+
@use '../../../mixins/ms';
8+
9+
///
10+
/// Tooltip styles
11+
///
12+
/// These Tooltip styles will be inlined in a Gutenberg Custom HTML block
13+
///
14+
/// TODO Consider making a Tooltip patterns component in the future
15+
///
16+
17+
$tooltip-color-background: var(--theme-color-background-secondary);
18+
$tooltip-color-border: #{sass-color.change(
19+
color.$brand-primary-darker,
20+
$alpha: 0.4
21+
)};
22+
$tooltip-color-shadow: #{sass-color.change(
23+
color.$brand-primary-darker,
24+
$alpha: 0.2
25+
)};
26+
27+
///
28+
/// 1. Positions tooltip vertically (below button)
29+
/// 2. Horizontally centers tooltip
30+
///
31+
32+
._c-tooltip {
33+
background: $tooltip-color-background;
34+
border-radius: size.$border-radius-medium;
35+
box-shadow: 0 0 0 size.$edge-medium $tooltip-color-border,
36+
size.$edge-large size.$edge-large 0 size.$edge-medium $tooltip-color-shadow;
37+
color: var(--theme-color-text-emphasis);
38+
inset-block-start: 100%; // 1
39+
inset-inline-start: 50%; // 2
40+
opacity: 0;
41+
padding: ms.step(-4);
42+
position: absolute; // 2
43+
transform: translateX(-50%); // 2
44+
white-space: nowrap;
45+
z-index: z-index.$alert;
46+
47+
///
48+
/// Tooltip arrow
49+
///
50+
/// The tooltip arrow is made up of two arrows, the first a background arrow
51+
/// that visually acts as the border and a second that sits on top as the
52+
/// actual (lighter colored) arrow that visually connects with the tooltip body.
53+
///
54+
/// 1. Magic number, design-based decision
55+
/// 2. Bottom-align the arrows on top of each other
56+
/// 3. The translateX value horizontally centers the arrows
57+
/// 4. The translateY value vertically aligns the arrows to top of tooltip body
58+
///
59+
60+
&::before,
61+
&::after {
62+
border-color: transparent transparent
63+
var(--arrow-color, $tooltip-color-border);
64+
border-style: solid;
65+
border-width: var(--arrow-size, 0.64em); // 1
66+
content: '';
67+
inset-block-end: var(--arrow-offset, 0); // 2
68+
inset-inline-start: 50%; // 3
69+
position: absolute; // 3
70+
transform: translate(-50%, -2.4em); // 3, 4
71+
}
72+
73+
///
74+
/// Foreground tooltip arrow
75+
///
76+
/// Updates the values for the arrow that is overlaid on top of the background
77+
/// arrow. Together, they form a bordered tooltip arrow.
78+
///
79+
/// 1. Magic number, design-based decision. I eye-balled the size of the
80+
/// overlaid arrow so that the visual border appeared the same width as the
81+
/// tooltip body border.
82+
/// 2. There was a 1px gap at some viewport sizes, this removed the gap
83+
///
84+
85+
&::after {
86+
--arrow-color: #{$tooltip-color-background};
87+
--arrow-size: 0.6em; // 1
88+
--arrow-offset: -0.125em; // 2
89+
}
90+
91+
///
92+
/// Shared animation state properties
93+
///
94+
95+
&.is-animating-intro,
96+
&.is-animating-outro {
97+
animation-duration: transition.$slow;
98+
animation-fill-mode: both;
99+
}
100+
101+
///
102+
/// Tooltip intro animation config
103+
///
104+
105+
&.is-animating-intro {
106+
animation-name: tooltipIntro;
107+
animation-timing-function: ease.$out_sine;
108+
109+
@media (prefers-reduced-motion: no-preference) {
110+
animation-name: tooltipIntroIncreasedMotion;
111+
}
112+
}
113+
114+
///
115+
/// Tooltip outro animation config
116+
///
117+
118+
&.is-animating-outro {
119+
animation-name: tooltipOutro;
120+
animation-timing-function: ease.$out_sine;
121+
}
122+
}
123+
124+
///
125+
/// Tooltip intro animation (default)
126+
///
127+
128+
@keyframes tooltipIntro {
129+
to {
130+
opacity: 1;
131+
}
132+
}
133+
134+
///
135+
/// Tooltip intro animation (increased motion)
136+
///
137+
/// 1. Only the Y value is changing. Before the animation, the horizontal
138+
/// translation is set to `-50%` to center the tooltip. We don't want to
139+
/// overwrite the X transformation when we add the Y transformation. Since
140+
/// there can only be a single `transform` property, we need to include the
141+
/// X value alongside the Y value.
142+
///
143+
144+
@keyframes tooltipIntroIncreasedMotion {
145+
from {
146+
animation-timing-function: ease.$out_sine;
147+
}
148+
149+
50% {
150+
animation-timing-function: ease.$in_out_sine;
151+
transform: translate(-50%, 15%); // 1
152+
}
153+
154+
to {
155+
opacity: 1;
156+
}
157+
}
158+
159+
///
160+
/// Tooltip outro animation
161+
///
162+
163+
@keyframes tooltipOutro {
164+
from {
165+
opacity: 1;
166+
}
167+
}

0 commit comments

Comments
 (0)