@eeacms/volto-tabs-block 1.2.10 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,94 +7,58 @@
7
7
  .loadAddonVariables();
8
8
 
9
9
  .tabs-block {
10
- &.edit {
11
- > .styled > .tabs > .ui.menu {
12
- margin: @menuMarginEdit;
13
- }
14
- }
15
-
16
- .menu-item-count {
17
- display: @menuItemCountDisplay;
10
+ [hidden] {
11
+ display: none !important;
18
12
  }
19
13
 
20
- > .styled > .tabs > .ui.menu {
21
- border: @menuBorder;
22
- margin: @menuMargin;
23
- background-color: @menuBackgroundColor;
24
- border-radius: @menuBorderRadius;
25
- box-shadow: @menuBoxShadow;
26
- overflow-x: auto;
27
-
28
- &.in-full-width {
29
- padding: 0 1rem;
30
- }
31
-
32
- &.ui.container > * {
33
- margin-bottom: initial !important;
34
- }
35
-
14
+ > .styled > .tabs > .ui.menu,
15
+ > .styled > .tabs > .ui.grid > .column > .ui.menu,
16
+ > .tabs > .ui.menu,
17
+ > .tabs > .ui.grid > .column > .ui.menu {
36
18
  &.menu-hidden {
37
19
  display: none;
38
20
  }
39
21
 
40
- &:after {
41
- display: none;
22
+ &.left {
23
+ justify-content: flex-start;
42
24
  }
43
25
 
44
- .ui.fluid.input {
45
- min-width: 80px;
26
+ &.right {
27
+ justify-content: flex-end;
46
28
  }
47
29
 
48
- .item {
49
- padding: @menuItemPadding;
50
- background: @menuItemBackground;
51
- color: @menuItemColor;
52
- font-family: @menuItemFontFamily;
53
- font-weight: @menuItemFontWeight;
54
-
55
- &:not(.menu-title) {
56
- font-size: @menuItemFontSize;
57
-
58
- p {
59
- font-size: @menuItemFontSize;
60
- }
61
- }
62
-
63
- .tab-title-input {
64
- min-width: 80px;
65
- max-width: 500px;
66
- align-self: center;
67
- border: none;
68
- color: @menuActiveItemColor;
69
- }
70
-
71
- &:hover {
72
- background: @menuItemHoverBackground;
73
- color: @menuItemHoverColor;
30
+ &.center {
31
+ justify-content: center;
32
+ }
74
33
 
75
- &.menu-title {
76
- background: @menuTitleHoverBackground;
77
- color: @menuTitleHoverColor;
78
- }
34
+ &.space-between {
35
+ .item.menu-title {
36
+ margin-right: auto;
79
37
  }
38
+ }
80
39
 
81
- &.active {
82
- background: @menuActiveItemBackground;
83
- color: @menuActiveItemColor;
84
- font-family: @menuItemFontFamily;
85
- font-weight: @menuActiveItemFontWeight;
86
-
87
- &:hover {
88
- background: @menuActiveItemHoverBackground;
89
- color: @menuActiveItemHoverColor;
40
+ &.text:not(.vertical) {
41
+ .item {
42
+ &:first-child {
43
+ padding-left: 0;
90
44
  }
91
45
  }
46
+ }
92
47
 
48
+ .item {
93
49
  &.menu-title {
94
50
  display: flex;
95
51
  flex-direction: column;
96
52
  align-items: flex-start;
53
+ justify-content: center;
97
54
  background: @menuTitleBackgrounnd;
55
+ font-size: @menuTitleFontSize;
56
+ font-weight: @menuTitleFontWeight;
57
+
58
+ &:hover {
59
+ background: @menuTitleHoverBackground;
60
+ color: @menuTitleHoverColor;
61
+ }
98
62
 
99
63
  .title {
100
64
  color: @menuTitleColor;
@@ -110,9 +74,26 @@
110
74
  }
111
75
  }
112
76
 
113
- &::before {
114
- width: @menuItemDividerWidth;
115
- background: @menuItemDividerBackground;
77
+ .menu-item-count {
78
+ display: @menuItemCountDisplay;
79
+ }
80
+ }
81
+
82
+ .ui.fluid.input {
83
+ min-width: 80px;
84
+ }
85
+ }
86
+
87
+ &.horizontal-responsive {
88
+ .horizontal-responsive.tabs > .ui.menu {
89
+ justify-content: space-between;
90
+
91
+ .menu-wrapper {
92
+ display: inherit;
93
+ overflow: hidden;
94
+ background: inherit;
95
+ font-family: inherit;
96
+ font-weight: inherit;
116
97
  }
117
98
  }
118
99
  }
@@ -136,109 +117,6 @@
136
117
  }
137
118
  }
138
119
  }
139
-
140
- /* MENU POSITION */
141
-
142
- > .styled > .tabs.inline {
143
- .menu {
144
- &.left {
145
- justify-content: flex-start;
146
- }
147
-
148
- &.right {
149
- justify-content: flex-end;
150
- }
151
-
152
- &.center {
153
- justify-content: center;
154
- }
155
-
156
- &.space-between {
157
- .menu-title {
158
- margin-right: auto;
159
- }
160
- }
161
-
162
- .item {
163
- &:first-child {
164
- padding-left: 0;
165
- }
166
- }
167
- }
168
- }
169
-
170
- > .styled > .tabs.side {
171
- &.left {
172
- .menu {
173
- .item {
174
- padding-top: 0;
175
- padding-left: 0;
176
- }
177
- }
178
- }
179
-
180
- &.right {
181
- .menu {
182
- .item {
183
- padding-top: 0;
184
- padding-right: 0;
185
-
186
- &.menu-title {
187
- padding-left: @menuItemPadding;
188
- }
189
- }
190
- }
191
- }
192
-
193
- .menu {
194
- &.left {
195
- align-items: flex-start;
196
- }
197
-
198
- &.right {
199
- align-items: flex-end;
200
- }
201
-
202
- &.center {
203
- align-items: center;
204
- }
205
-
206
- &.space-between {
207
- .menu-title {
208
- margin-bottom: auto;
209
- }
210
- }
211
- }
212
- }
213
-
214
- &.flex-start {
215
- > .tabs.side > .ui.menu {
216
- justify-content: flex-start;
217
- }
218
- }
219
-
220
- &.center {
221
- > .tabs.side > .ui.menu {
222
- justify-content: center;
223
- }
224
- }
225
-
226
- &.flex-end {
227
- > .tabs.side > .ui.menu {
228
- justify-content: flex-end;
229
- }
230
- }
231
-
232
- @media only screen and (max-width: @menuLargestMobileScreen) {
233
- > .styled > .side.default.tabs {
234
- flex-direction: column;
235
-
236
- > .ui.menu {
237
- flex-basis: 100%;
238
- order: 0;
239
- }
240
- }
241
- }
242
120
  }
243
121
 
244
122
  .loadAddonOverrides();
@@ -1,10 +1,8 @@
1
- @menuMargin: 0;
2
- @menuMarginEdit: 1rem 0;
3
- @menuBoxShadow: none;
4
- @menuBackgroundColor: transparent;
5
- @menuBorder: none;
6
- @menuBorderRadius: 0.28571429rem;
1
+ /*******************************
2
+ Tabs menu
3
+ *******************************/
7
4
 
5
+ /* Menu title */
8
6
  @menuTitleFontSize: 24px;
9
7
  @menuTitleFontWeight: normal;
10
8
  @menuTitleColor: #013C60;
@@ -12,27 +10,8 @@
12
10
  @menuTitleHoverColor: #013C60;
13
11
  @menuTitleHoverBackground: none;
14
12
 
13
+ /* Menu description */
15
14
  @menuDescriptionColor: #636363;
16
15
 
16
+ /* Menu item */
17
17
  @menuItemCountDisplay: none;
18
- @menuItemDividerWidth: 0;
19
- @menuItemDividerBackground: rgba(34, 36, 38, 0.1);
20
- @menuItemFontFamily: 'Raleway', sans-serif;
21
- @menuItemPadding: 1rem;
22
-
23
- @menuFirstItemPadding: @menuItemPadding;
24
-
25
- @menuItemFontSize: 16px;
26
- @menuItemFontWeight: normal;
27
- @menuItemColor: #636363;
28
- @menuItemBackground: none;
29
- @menuItemHoverColor: #878F93;
30
- @menuItemHoverBackground: none;
31
-
32
- @menuActiveItemFontWeight: normal;
33
- @menuActiveItemColor: #04A77D;
34
- @menuActiveItemBackground: none;
35
- @menuActiveItemHoverColor: #04c290;
36
- @menuActiveItemHoverBackground: none;
37
-
38
- @menuLargestMobileScreen: 767px;
@@ -0,0 +1,65 @@
1
+ @import './globals.less';
2
+
3
+ @addon: 'volto-addons';
4
+ @addontype: 'tabsblock';
5
+ @addonelement: 'tabs';
6
+
7
+ .loadAddonVariables();
8
+
9
+ .tabs-block {
10
+ > .styled {
11
+ display: flex !important;
12
+ flex: 1;
13
+ flex-flow: column;
14
+ }
15
+
16
+ .ui.segment.tab {
17
+ padding: @tabPanePadding;
18
+ }
19
+
20
+ .ui.container.tab {
21
+ padding-top: @verticalPadding;
22
+ padding-bottom: @verticalPadding;
23
+ }
24
+
25
+ > .styled > .default.tabs,
26
+ > .default.tabs {
27
+ display: flex;
28
+ flex-direction: column;
29
+
30
+ > .ui.tab {
31
+ display: flex;
32
+ flex: 1;
33
+ flex-direction: column;
34
+ }
35
+ }
36
+
37
+ &.flex-start {
38
+ > .styled > .default.tabs,
39
+ > .default.tabs {
40
+ > .ui.tab {
41
+ justify-content: flex-start;
42
+ }
43
+ }
44
+ }
45
+
46
+ &.flex-end {
47
+ > .styled > .default.tabs,
48
+ > .default.tabs {
49
+ > .ui.tab {
50
+ justify-content: flex-end;
51
+ }
52
+ }
53
+ }
54
+
55
+ &.center {
56
+ > .styled > .default.tabs,
57
+ > .default.tabs {
58
+ > .ui.tab {
59
+ justify-content: center;
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ .loadAddonOverrides();
@@ -0,0 +1,9 @@
1
+ /*******************************
2
+ Tabs block
3
+ *******************************/
4
+
5
+ @verticalPadding: 1em;
6
+ @horizontalPadding: 0;
7
+
8
+ /* Tab pane */
9
+ @tabPanePadding: @verticalPadding @horizontalPadding;
@@ -0,0 +1,76 @@
1
+ export function positionedOffset(targetElement, container) {
2
+ let element = targetElement;
3
+ const document = element.ownerDocument;
4
+ if (!document) {
5
+ return;
6
+ }
7
+
8
+ const documentElement = document.documentElement;
9
+ if (!documentElement) {
10
+ return;
11
+ }
12
+
13
+ const HTMLElement = document.defaultView.HTMLElement;
14
+
15
+ let top = 0;
16
+ let left = 0;
17
+ const height = element.offsetHeight;
18
+ const width = element.offsetWidth;
19
+
20
+ while (!(element === document.body || element === container)) {
21
+ top += element.offsetTop || 0;
22
+ left += element.offsetLeft || 0;
23
+
24
+ if (element.offsetParent instanceof HTMLElement) {
25
+ element = element.offsetParent;
26
+ } else {
27
+ return;
28
+ }
29
+ }
30
+
31
+ let scrollHeight;
32
+ let scrollWidth;
33
+ let measuredContainer;
34
+
35
+ if (
36
+ !container ||
37
+ container === document ||
38
+ container === document.defaultView ||
39
+ container === document.documentElement ||
40
+ container === document.body
41
+ ) {
42
+ measuredContainer = documentElement;
43
+ scrollHeight = getDocumentHeight(document.body, documentElement);
44
+ scrollWidth = getDocumentWidth(document.body, documentElement);
45
+ } else if (container instanceof HTMLElement) {
46
+ measuredContainer = container;
47
+ scrollHeight = container.scrollHeight;
48
+ scrollWidth = container.scrollWidth;
49
+ } else {
50
+ return;
51
+ }
52
+
53
+ const bottom = scrollHeight - (top + height);
54
+ const right = scrollWidth - (left + width);
55
+ return { top, left, bottom, right, _container: measuredContainer };
56
+ }
57
+
58
+ export function getDocumentHeight(documentBody, documentElement) {
59
+ return Math.max(
60
+ documentBody.scrollHeight,
61
+ documentElement.scrollHeight,
62
+ documentBody.offsetHeight,
63
+ documentElement.offsetHeight,
64
+ documentElement.clientHeight,
65
+ );
66
+ }
67
+
68
+ export function getDocumentWidth(documentBody, documentElement) {
69
+ return Math.max(
70
+ documentBody.scrollWidth,
71
+ documentElement.scrollWidth,
72
+ documentBody.offsetWidth,
73
+ documentElement.offsetWidth,
74
+ documentElement.clientWidth,
75
+ );
76
+ }
@@ -1,3 +1,43 @@
1
1
  import SimpleMarkdown from './SimpleMarkdown';
2
2
 
3
- export { SimpleMarkdown };
3
+ const getMenuPosition = (data) => {
4
+ const positions = {
5
+ top: 'top',
6
+ bottom: 'bottom',
7
+ 'left side': 'left',
8
+ 'right side': 'right',
9
+ };
10
+ const position = positions[data.menuPosition];
11
+ if (['left', 'right'].includes(position)) {
12
+ return {
13
+ vertical: true,
14
+ direction: position,
15
+ };
16
+ }
17
+ if (['bottom'].includes(position)) {
18
+ return {
19
+ attached: position,
20
+ };
21
+ }
22
+ return {};
23
+ };
24
+
25
+ const toggleItem = (container, item, hidden) => {
26
+ // Set visibility to hidden, instead of .hidden attribute
27
+ // so we can still calculate distance accurately
28
+ item.style.visibility = hidden ? 'hidden' : '';
29
+ // item.style.display = hidden ? 'none' : 'flex';
30
+ // Get tab-item name, if present, so we can match it up with the dropdown menu
31
+ const itemData = item.getAttribute('item-data');
32
+ if (itemData) {
33
+ const itemToHide = container.querySelector(
34
+ `[underline-item-data="${itemData}"]`,
35
+ );
36
+ if (itemToHide instanceof HTMLElement) {
37
+ itemToHide.hidden = !hidden;
38
+ }
39
+ }
40
+ };
41
+
42
+ export { SimpleMarkdown, getMenuPosition, toggleItem };
43
+ export * from './dimensions';