This repository has been archived by the owner on Dec 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
c-sf-block.scss
193 lines (163 loc) · 5.4 KB
/
c-sf-block.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// TODO: Reduce nesting further by splitting out more components.
//
// Theres quite a lot of nesting in here which makes parsing some segments difficult.
// Some of this is to deal with the fact that .c-sf-block can contain many .c-sf-block's and so is
// legitimate. A lot of these would ideally be their own components (eg the actions) however there
// is a lot of interdependancy of the elements because of COLLAPSIBLE vs SIMPLE vs default which
// makes this hard without fairly intensive rethinking of the HTML.
//
// However, the new classes adequately sanitise streamfield only CSS so am leaving this for
// now to avoid blocking the release of the new Streamfield. -@jonnyscholes
// TODO: Consider visually moving .c-sf-block__type and .c-sf-block__actions based on COLLAPSIBLE vs
// SIMPLE vs default using CSS only instead of moving HTML around. -@jonnyscholes
.c-sf-block {
flex: 1 1 auto;
margin: $block-margin-vertical $block-margin-horizontal;
border: 1px solid $block-border-color;
border-radius: $border-radius;
background: white;
transition: border-color $hover-transition-duration ease-in-out;
transition-property: border-color, box-shadow;
&__header {
display: flex;
justify-content: space-between;
align-items: center;
padding-left: $header-padding-horizontal;
user-select: none;
transition: background-color $hover-transition-duration ease-in-out;
cursor: default;
border-top-left-radius: $border-radius;
&--collapsible {
cursor: pointer;
}
&--sortable {
cursor: grab;
}
&__title {
display: inline-block;
flex: 1 1 auto;
margin: 0;
color: $header-text-color;
vertical-align: middle;
&__icon {
color: currentColor;
transition: color $hover-transition-duration ease-in-out;
}
}
}
&__content {
&-inner {
padding: 12px;
}
}
&__actions {
white-space: nowrap;
&__single {
appearance: none;
border: 0 none;
padding: $header-padding-vertical $header-padding-horizontal;
background: none;
cursor: pointer;
color: $header-text-color;
opacity: 1;
transition: opacity $hover-transition-duration ease-in-out;
transition-property: opacity, color;
font-size: $action-font-size;
i {
font-style: normal;
&:before {
margin: 0;
}
}
&[disabled] {
opacity: 0.2;
pointer-events: none;
}
}
}
&__type {
margin-right: $header-padding-horizontal * 2;
text-transform: uppercase;
text-align: right;
font-size: 80%;
line-height: 100%;
color: $header-text-color;
vertical-align: middle;
user-select: none;
}
&.c-sf-block--error {
border-color: $error-border-color;
> .c-sf-block__header {
background: $error-background-color;
}
&:hover,
&:focus,
&:focus-within {
border-color: $error-border-color-focus;
> .c-sf-block__header {
background: $error-background-color;
}
}
}
&.SIMPLE {
display: flex;
flex-flow: row nowrap;
> .c-sf-block__header {
position: relative;
flex: 0 0 auto;
padding: $header-padding-vertical $header-padding-horizontal;
border-bottom-left-radius: $border-radius;
.c-sf-block__header__title {
position: sticky;
top: $grid-gutter-width / 4;
bottom: $grid-gutter-width / 4;
}
}
> .c-sf-block__content {
flex: 1 1 auto;
display: flex;
flex-flow: column nowrap;
justify-content: space-around;
width: 0; // Trick to prevent content from overflowing, while
// allowing for some overflow, like Draftail tooltips.
}
> .c-sf-block__aside {
display: flex;
flex-flow: column nowrap;
align-items: flex-end;
.c-sf-block__type {
margin: 0 $header-padding-horizontal
$header-padding-vertical $header-padding-horizontal;
}
}
}
&.COLLAPSIBLE {
> .c-sf-block__header {
border-top-right-radius: $border-radius;
.c-sf-block__header__title {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.c-sf-block__header__title__icon {
margin-right: $header-padding-horizontal;
}
> .c-sf-block__aside {
flex: 0 0 auto;
}
}
}
&:hover,
&:focus,
&:focus-within {
border-color: $block-border-color-focus;
box-shadow: 3px 2px 3px -1px rgba(0, 0, 0, 0.1);
> .c-sf-block__header {
background: $block-hover-background;
.c-sf-block__header__title,
.c-sf-block__actions__single {
color: $header-text-color-focus;
}
}
}
}