@vev/silke 1.0.10 → 1.0.12

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.
Files changed (191) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/chunk-4MB64AQL.js +22 -0
  3. package/dist/chunk-4MB64AQL.js.LEGAL.txt +8 -0
  4. package/dist/chunk-4MB64AQL.js.map +7 -0
  5. package/dist/index.js +9 -25
  6. package/dist/index.js.LEGAL.txt +6 -9
  7. package/dist/index.js.map +4 -4
  8. package/dist/silke-code-editor-HZRG3D6C.js +23 -0
  9. package/dist/silke-code-editor-HZRG3D6C.js.map +7 -0
  10. package/dist/styles.css +4338 -2599
  11. package/esbuild.config.mjs +2 -1
  12. package/jest.config.js +2 -1
  13. package/package.json +12 -8
  14. package/src/_variables.scss +121 -1
  15. package/src/components/index.ts +6 -0
  16. package/src/components/silke-autocomplete-field/autocomplete-item.tsx +15 -13
  17. package/src/components/silke-autocomplete-field/autocomplete-tags.tsx +14 -7
  18. package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +31 -4
  19. package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +8 -6
  20. package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +64 -23
  21. package/src/components/silke-box/silke-box.scss +21 -47
  22. package/src/components/silke-box/silke-box.tsx +23 -31
  23. package/src/components/silke-breadcrumbs/silke-breadcrumb.scss +3 -3
  24. package/src/components/silke-button/index.ts +3 -1
  25. package/src/components/silke-button/silke-big-button.scss +38 -0
  26. package/src/components/silke-button/silke-big-button.tsx +49 -0
  27. package/src/components/silke-button/silke-button-set.tsx +15 -3
  28. package/src/components/silke-button/silke-button.mdx +41 -19
  29. package/src/components/silke-button/silke-button.scss +97 -90
  30. package/src/components/silke-button/silke-button.tsx +20 -5
  31. package/src/components/silke-button/silke-file-select-button.tsx +86 -0
  32. package/src/components/silke-card/silke-card-grid.tsx +9 -9
  33. package/src/components/silke-card/silke-card.mdx +23 -9
  34. package/src/components/silke-card/silke-card.scss +92 -39
  35. package/src/components/silke-card/silke-card.tsx +50 -27
  36. package/src/components/silke-checkbox/silke-checkbox.scss +39 -17
  37. package/src/components/silke-checkbox/silke-checkbox.tsx +4 -1
  38. package/src/components/silke-code-editor/index.tsx +12 -0
  39. package/src/components/silke-code-editor/silke-code-editor.mdx +97 -0
  40. package/src/components/silke-code-editor/silke-code-editor.tsx +52 -0
  41. package/src/components/silke-code-snippet/silke-code-snippet.scss +2 -10
  42. package/src/components/silke-code-snippet/silke-code-snippet.tsx +10 -3
  43. package/src/components/silke-color-palettes/silke-color-palette.tsx +11 -2
  44. package/src/components/silke-color-picker/color-picker.scss +10 -6
  45. package/src/components/silke-color-picker/silke-color-info.tsx +14 -4
  46. package/src/components/silke-color-picker/silke-color-picker-button.tsx +4 -3
  47. package/src/components/silke-color-picker/silke-color-picker.tsx +4 -2
  48. package/src/components/silke-color-picker/silke-opacity-slider.tsx +11 -12
  49. package/src/components/silke-color-swatches/silke-color-swatch-button.tsx +10 -4
  50. package/src/components/silke-color-swatches/silke-swatches.tsx +2 -2
  51. package/src/components/silke-content-column/index.ts +1 -0
  52. package/src/components/silke-content-column/silke-content-column.mdx +7 -0
  53. package/src/components/silke-content-column/silke-content-column.scss +39 -0
  54. package/src/components/silke-content-column/silke-content-column.tsx +14 -0
  55. package/src/components/silke-context-menu/silke-context-menu-item.tsx +9 -4
  56. package/src/components/silke-context-menu/silke-context-menu.mdx +16 -12
  57. package/src/components/silke-context-menu/silke-context-menu.scss +16 -0
  58. package/src/components/silke-context-menu/silke-context-menu.tsx +62 -39
  59. package/src/components/silke-css-number-field/silke-css-context.tsx +1 -0
  60. package/src/components/silke-css-number-field/silke-css-number-field.scss +18 -3
  61. package/src/components/silke-css-number-field/silke-css-number-field.tsx +32 -13
  62. package/src/components/silke-css-number-field/utils.ts +2 -0
  63. package/src/components/silke-divider/silke-divider.scss +4 -2
  64. package/src/components/silke-drawer/silke-drawer.scss +3 -3
  65. package/src/components/silke-drawer/silke-drawer.tsx +3 -3
  66. package/src/components/silke-form/silke-form.tsx +1 -9
  67. package/src/components/silke-form-schema/fields/array-field-inline.tsx +2 -3
  68. package/src/components/silke-form-schema/fields/array-field-modal.tsx +1 -1
  69. package/src/components/silke-form-schema/fields/array-field.tsx +2 -2
  70. package/src/components/silke-form-schema/fields/event-field.tsx +120 -0
  71. package/src/components/silke-form-schema/fields/icon-field.tsx +1 -1
  72. package/src/components/silke-form-schema/fields/image-field.tsx +1 -1
  73. package/src/components/silke-form-schema/fields/link-field.tsx +8 -1
  74. package/src/components/silke-form-schema/fields/number-field.tsx +24 -8
  75. package/src/components/silke-form-schema/fields/object-field.tsx +1 -1
  76. package/src/components/silke-form-schema/fields/select-field.tsx +9 -2
  77. package/src/components/silke-form-schema/fields/styles.scss +2 -2
  78. package/src/components/silke-form-schema/fields/toggle-field.tsx +14 -13
  79. package/src/components/silke-form-schema/fields/upload-field.tsx +37 -0
  80. package/src/components/silke-form-schema/fields/utils/generate-image.ts +3 -4
  81. package/src/components/silke-form-schema/fields/utils/generate-title.ts +1 -3
  82. package/src/components/silke-form-schema/index.ts +1 -0
  83. package/src/components/silke-form-schema/silke-extended-fields-context.tsx +22 -0
  84. package/src/components/silke-form-schema/silke-schema-field.tsx +19 -6
  85. package/src/components/silke-icon/silke-icon.scss +3 -2
  86. package/src/components/silke-icon/silke-icon.tsx +7 -3
  87. package/src/components/silke-icon/silke-shape.tsx +3 -2
  88. package/src/components/silke-icon-picker/emoji-tab.tsx +2 -2
  89. package/src/components/silke-icon-picker/icons-tab.tsx +1 -1
  90. package/src/components/silke-icon-picker/silke-icon-picker.tsx +1 -1
  91. package/src/components/silke-iframe-portal/index.ts +4 -0
  92. package/src/components/silke-iframe-portal/silke-iframe-context.ts +6 -0
  93. package/src/components/silke-iframe-portal/silke-iframe-css-link.tsx +20 -0
  94. package/src/components/silke-iframe-portal/silke-iframe-portal.mdx +34 -0
  95. package/src/components/silke-iframe-portal/silke-iframe-portal.tsx +77 -0
  96. package/src/components/silke-iframe-portal/silke-iframe-script.tsx +20 -0
  97. package/src/components/silke-link/silke-link.scss +2 -2
  98. package/src/components/silke-link/silke-link.tsx +8 -9
  99. package/src/components/silke-list/silke-list.scss +1 -1
  100. package/src/components/silke-list-card/index.ts +1 -0
  101. package/src/components/silke-list-card/silke-list-card.mdx +50 -0
  102. package/src/components/silke-list-card/silke-list-card.scss +57 -0
  103. package/src/components/silke-list-card/silke-list-card.tsx +65 -0
  104. package/src/components/silke-loader/index.ts +1 -0
  105. package/src/components/silke-loader/silke-loader-overlay.tsx +63 -0
  106. package/src/components/silke-loader/silke-loader.scss +112 -0
  107. package/src/components/silke-loader/silke-loader.tsx +1 -0
  108. package/src/components/silke-modal/silke-confirmation-modal.tsx +1 -1
  109. package/src/components/silke-modal/silke-modal.mdx +1 -1
  110. package/src/components/silke-modal/silke-modal.scss +16 -10
  111. package/src/components/silke-modal/silke-modal.tsx +65 -47
  112. package/src/components/silke-navigation-link/silke-navigation-link.scss +69 -41
  113. package/src/components/silke-navigation-link/silke-navigation-link.tsx +26 -14
  114. package/src/components/silke-notification/confetti.tsx +164 -0
  115. package/src/components/silke-notification/silke-notification.mdx +137 -20
  116. package/src/components/silke-notification/silke-notification.scss +116 -89
  117. package/src/components/silke-notification/silke-notification.tsx +44 -113
  118. package/src/components/silke-object-field/silke-object-field.tsx +1 -1
  119. package/src/components/silke-overflow-menu/silke-overflow-menu.mdx +2 -2
  120. package/src/components/silke-overflow-menu/silke-overflow-menu.scss +12 -4
  121. package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +53 -30
  122. package/src/components/silke-popover/silke-popover.mdx +2 -2
  123. package/src/components/silke-popover/silke-popover.tsx +23 -5
  124. package/src/components/silke-progress-indicator/silke-progress-indicator.scss +5 -5
  125. package/src/components/silke-radio-button/silke-radio-button-group.tsx +1 -1
  126. package/src/components/silke-radio-button/silke-radio-button.scss +24 -9
  127. package/src/components/silke-search-field/silke-search-field.tsx +10 -5
  128. package/src/components/silke-select-field/silke-select-field.mdx +11 -5
  129. package/src/components/silke-skeleton/silke-skeleton.scss +2 -2
  130. package/src/components/silke-slider/range-slider.scss +13 -10
  131. package/src/components/silke-slider/silke-slider.tsx +5 -0
  132. package/src/components/silke-sortable-list/silke-nested-sortable-item.tsx +105 -0
  133. package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +37 -25
  134. package/src/components/silke-sortable-list/silke-nested-sortable-list.tsx +180 -127
  135. package/src/components/silke-sortable-list/silke-nested-sortable-utils.ts +53 -23
  136. package/src/components/silke-sortable-list/silke-sortable-item-wrapper.tsx +1 -1
  137. package/src/components/silke-sortable-list/silke-sortable-list.mdx +12 -16
  138. package/src/components/silke-sortable-list/silke-sortable-list.scss +39 -29
  139. package/src/components/silke-sortable-list/silke-sortable-list.tsx +27 -15
  140. package/src/components/silke-steps/index.ts +1 -0
  141. package/src/components/silke-steps/silke-steps.mdx +60 -0
  142. package/src/components/silke-steps/silke-steps.scss +14 -0
  143. package/src/components/silke-steps/silke-steps.tsx +53 -0
  144. package/src/components/silke-table/silke-table.mdx +44 -13
  145. package/src/components/silke-table/silke-table.scss +19 -9
  146. package/src/components/silke-table/silke-table.tsx +80 -71
  147. package/src/components/silke-table/table-row.tsx +11 -6
  148. package/src/components/silke-tabs/silke-tab.tsx +4 -0
  149. package/src/components/silke-tabs/silke-tabs.scss +18 -15
  150. package/src/components/silke-tabs/silke-tabs.tsx +4 -7
  151. package/src/components/silke-tag/silke-tag.mdx +36 -2
  152. package/src/components/silke-tag/silke-tag.scss +49 -30
  153. package/src/components/silke-tag/silke-tag.tsx +21 -6
  154. package/src/components/silke-text/silke-text-types.ts +2 -1
  155. package/src/components/silke-text/silke-text.mdx +28 -20
  156. package/src/components/silke-text/silke-text.scss +8 -7
  157. package/src/components/silke-text/silke-title.scss +1 -1
  158. package/src/components/silke-text-field/silke-text-field-outline.tsx +4 -4
  159. package/src/components/silke-text-field/silke-text-field.mdx +32 -14
  160. package/src/components/silke-text-field/silke-text-field.scss +41 -23
  161. package/src/components/silke-text-field/silke-text-field.tsx +13 -5
  162. package/src/components/silke-text-field/text-field-context.tsx +1 -1
  163. package/src/components/silke-theme-editor/index.ts +1 -0
  164. package/src/components/silke-theme-editor/silke-theme-editor.tsx +165 -0
  165. package/src/components/silke-tile/silke-tile.scss +13 -18
  166. package/src/components/silke-tile/silke-tile.tsx +11 -17
  167. package/src/components/silke-toggle/silke-toggle.scss +17 -9
  168. package/src/components/silke-toggle/silke-toggle.tsx +1 -1
  169. package/src/components/silke-toolbar/silke-toolbar.scss +1 -1
  170. package/src/components/silke-tooltip/silke-definition-tooltip.tsx +14 -6
  171. package/src/components/silke-tooltip/silke-icon-tooltip.tsx +48 -34
  172. package/src/components/silke-tooltip/silke-interactive-tooltip.tsx +5 -3
  173. package/src/components/silke-tooltip/silke-tooltip.mdx +69 -2
  174. package/src/components/silke-tooltip/silke-tooltip.scss +71 -46
  175. package/src/components/silke-tooltip/silke-tooltip.tsx +142 -52
  176. package/src/components/silke-tooltip/utils.ts +93 -0
  177. package/src/components/silke-upload-field/silke-upload-field.mdx +14 -0
  178. package/src/components/silke-upload-field/silke-upload-field.scss +26 -17
  179. package/src/components/silke-upload-field/silke-upload-field.tsx +37 -14
  180. package/src/docs/app.tsx +118 -25
  181. package/src/docs/components/code-block/code-block.scss +0 -2
  182. package/src/docs/components/code-block/code-block.tsx +17 -9
  183. package/src/hooks/drag-and-drop/use-drag.tsx +5 -1
  184. package/src/hooks/drag-and-drop/use-drop.tsx +5 -4
  185. package/src/icons.tsx +194 -10
  186. package/src/index.mdx +66 -1
  187. package/src/main.tsx +5 -2
  188. package/src/silke-theme-provider.tsx +51 -3
  189. package/src/styles/core.scss +56 -91
  190. package/webpack.docs.ts +1 -3
  191. package/webpack.config.ts +0 -131
@@ -1,11 +1,16 @@
1
- @use '../../variables' as *;
1
+ @use "../../variables" as *;
2
2
  $focus-border-width: 2px;
3
3
  $widths: "tiny" 256px, "small" 512px, "medium" 768px, "large" 1024px;
4
4
 
5
+ body{
6
+ --tile-background: var(--color-neutral-5);
7
+ --tile-background-hover: rgba(var(--color-neutral-5-rgb), 0.32);
8
+ --tile-background-active: rgba(var(--color-neutral-5-rgb), 0.08);
9
+ }
10
+
5
11
  .tile {
6
12
  position: relative;
7
- border: 1px solid var(--color-neutral-low-medium);
8
- border-radius: 4px;
13
+ background: var(--tile-background);
9
14
 
10
15
  &:focus {
11
16
  outline: none;
@@ -13,8 +18,8 @@ $widths: "tiny" 256px, "small" 512px, "medium" 768px, "large" 1024px;
13
18
 
14
19
  &:focus-visible,
15
20
  &.selected {
16
- box-shadow: 0 0 0 1px var(--color-neutral-high-pure);
17
- border-color: var(--color-neutral-high-pure);
21
+ box-shadow: 0 0 0 1px var(--color-neutral-100);
22
+ border-color: var(--color-neutral-100);
18
23
  }
19
24
  }
20
25
 
@@ -23,18 +28,16 @@ $widths: "tiny" 256px, "small" 512px, "medium" 768px, "large" 1024px;
23
28
  transition: background ease-in-out 100ms;
24
29
 
25
30
  &:hover {
26
- background-color: var(--color-neutral-low-medium);
27
- border-color: var(--color-neutral-high-dark);
31
+ background-color: var(--tile-background-hover);
28
32
  }
29
33
 
30
34
  &:active {
31
- background: var(--color-neutral-low-soft);
32
- border-color: var(--color-neutral-high-pure);
35
+ background: var(--tile-background-active);
33
36
  }
34
37
  }
35
38
 
36
39
  .icon {
37
- font-size:16px;
40
+ font-size: 16px;
38
41
  }
39
42
 
40
43
  .tags {
@@ -47,14 +50,6 @@ $widths: "tiny" 256px, "small" 512px, "medium" 768px, "large" 1024px;
47
50
  }
48
51
  }
49
52
 
50
- .silkeTileActions > *:first-child {
51
- border-bottom-left-radius: 3px;
52
- }
53
-
54
- .silkeTileActions > *:last-child {
55
- border-bottom-right-radius: 3px;
56
- }
57
-
58
53
  @each $name, $size in $widths {
59
54
  .#{$name} {
60
55
  max-width: $size;
@@ -1,17 +1,17 @@
1
1
  import classnames from 'classnames/bind';
2
+ import React, { Children, ReactNode, useState } from 'react';
3
+ import useCollapse from 'react-collapsed';
4
+ import { KeyCode } from '../../helpers/key-code';
5
+ import { BoxDivProps, SilkeBox } from '../silke-box';
2
6
  import { SilkeButton, SilkeButtonSet, SilkeButtonSetProps } from '../silke-button';
3
7
  import ButtonContext from '../silke-button/context';
4
8
  import { SilkeIcon, SilkeIcons } from '../silke-icon';
5
9
  import { SilkeImage } from '../silke-image';
6
10
  import { SilkeOverflowMenu, SilkeOverflowMenuItem } from '../silke-overflow-menu';
7
11
  import { SilkeSkeleton } from '../silke-skeleton';
12
+ import { SilkeTagGreen } from '../silke-tag';
8
13
  import { SilkeText, SilkeTitle } from '../silke-text';
9
- import React, { Children, ReactNode, useEffect, useState } from 'react';
10
- import { BoxDivProps, SilkeBox } from '../silke-box';
11
14
  import styles from './silke-tile.scss';
12
- import { SilkeTagGreen } from '../silke-tag';
13
- import { KeyCode } from '../../helpers/key-code';
14
- import useCollapse from 'react-collapsed';
15
15
 
16
16
  const cl = classnames.bind(styles);
17
17
 
@@ -42,7 +42,8 @@ export type SilkeTileProps = {
42
42
  expandCloseText?: string;
43
43
  expandLoadingText?: string;
44
44
  hideSelectedCheck?: boolean;
45
- } & Omit<BoxDivProps, 'title' | 'width' | 'height' | 'size'>;
45
+ children?: React.ReactNode | React.ReactNode[];
46
+ } & Omit<BoxDivProps, 'title' | 'width' | 'height' | 'size' | 'children'>;
46
47
 
47
48
  export function SilkeTile({
48
49
  image,
@@ -102,6 +103,7 @@ export function SilkeTile({
102
103
  return (
103
104
  <SilkeBox
104
105
  column
106
+ rounded="medium"
105
107
  role={rest.onClick ? 'link' : undefined}
106
108
  tabIndex={rest.onClick ? 0 : undefined}
107
109
  onKeyUp={
@@ -123,7 +125,7 @@ export function SilkeTile({
123
125
  <SilkeSkeleton style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }} />
124
126
  )}
125
127
  {image && <SilkeImage aspectRatio="16:9" src={image} />}
126
- <SilkeBox pad="m" gap="m" flex>
128
+ <SilkeBox pad="l" gap="m" flex>
127
129
  <SilkeBox gap="xs" column flex>
128
130
  {(icon || title || subTitle) && (
129
131
  <SilkeBox vAlign="center" gap="s">
@@ -178,7 +180,7 @@ export function SilkeTile({
178
180
  </SilkeBox>
179
181
  {selected && !hideSelectedCheck && (
180
182
  <SilkeBox column vAlign="spread" hAlign="center" width="m">
181
- <SilkeText color="primary">
183
+ <SilkeText color="accent-50">
182
184
  <SilkeIcon icon="check.circle" />
183
185
  </SilkeText>
184
186
  </SilkeBox>
@@ -194,16 +196,8 @@ type SilkeTileActions = Omit<SilkeButtonSetProps, 'size'>;
194
196
  export function SilkeTileActions({ children, className, ...rest }: SilkeTileActions) {
195
197
  const hasAtLeastTwoButtons = React.Children.toArray(children).filter(Boolean).length > 1;
196
198
 
197
- const classNames = className ? [styles.silkeTileActions, className] : [styles.silkeTileActions];
198
-
199
199
  return hasAtLeastTwoButtons ? (
200
- <SilkeButtonSet
201
- gap={false}
202
- kind="primary"
203
- size="bleed"
204
- className={classNames.join(' ')}
205
- {...rest}
206
- >
200
+ <SilkeButtonSet gap="s" hAlign="end" pad="m" kind="primary" className={className} {...rest}>
207
201
  {children}
208
202
  </SilkeButtonSet>
209
203
  ) : (
@@ -1,14 +1,14 @@
1
- @use '../../variables' as *;
1
+ @use "../../variables" as *;
2
2
  @use "sass:math";
3
3
 
4
- $bg-off: var(--color-neutral-high-dark);
5
- $bg-on: var(--color-brand-secondary-bright);
4
+ $bg-off: var(--color-neutral-30);
5
+ $bg-on: var(--color-accent-30);
6
6
 
7
7
  .container {
8
8
  position: relative;
9
9
  cursor: pointer;
10
10
  user-select: none;
11
- color: var(--color-neutral-high-pure);
11
+ color: var(--color-neutral-100);
12
12
 
13
13
  input {
14
14
  position: absolute;
@@ -17,8 +17,9 @@ $bg-on: var(--color-brand-secondary-bright);
17
17
  width: 0;
18
18
  &:checked ~ .switch {
19
19
  background-color: $bg-on;
20
- &:after {
20
+ &::after {
21
21
  transform: translateX(calc(100% + 4px));
22
+ background: var(--color-neutral-100);
22
23
  }
23
24
  }
24
25
 
@@ -30,7 +31,7 @@ $bg-on: var(--color-brand-secondary-bright);
30
31
  }
31
32
 
32
33
  .error {
33
- color: var(--color-feedback-warning-spark);
34
+ color: var(--color-warning-30);
34
35
  }
35
36
 
36
37
  .switch {
@@ -41,13 +42,13 @@ $bg-on: var(--color-brand-secondary-bright);
41
42
  background-color: $bg-off;
42
43
  transition: background-color 100ms ease;
43
44
 
44
- &:after {
45
+ &::after {
45
46
  content: "";
46
47
  display: block;
47
48
  width: calc(50% - #{$space-xxs});
48
49
  height: 100%;
49
50
  border-radius: 50%;
50
- background: var(--color-neutral-high-pure);
51
+ background: var(--color-neutral-90);
51
52
  transform: translateX(0);
52
53
  transition: transform 100ms ease;
53
54
  }
@@ -61,7 +62,14 @@ $bg-on: var(--color-brand-secondary-bright);
61
62
  }
62
63
 
63
64
  .disabled {
64
- color: var(--color-neutral-low-soft);
65
+ .switch {
66
+ background: var(--color-neutral-30);
67
+ }
68
+ .switch {
69
+ &::after {
70
+ background: var(--color-neutral-50);
71
+ }
72
+ }
65
73
  cursor: not-allowed;
66
74
  pointer-events: none;
67
75
  .switch {
@@ -57,7 +57,7 @@ export function SilkeToggle(props: Props) {
57
57
  />
58
58
  {label && <SilkeText weight="strong">{label}</SilkeText>}
59
59
  {help && (
60
- <SilkeText tag="span" flex color="secondary">
60
+ <SilkeText tag="span" flex color="neutral-80">
61
61
  {help}
62
62
  </SilkeText>
63
63
  )}
@@ -5,7 +5,7 @@
5
5
 
6
6
  // Adding border like this to not make container 1px lower
7
7
  &:before {
8
- background-color: rgba(var(--color-neutral-high-pure-rgb), var(--opacity-level-light));
8
+ background-color: rgba(var(--color-neutral-100-rgb), var(--opacity-level-light));
9
9
  position: absolute;
10
10
  content:"";
11
11
  bottom: 0;
@@ -1,14 +1,16 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
- import { SilkeTooltip } from '.';
2
+ import { SilkeTooltip, SilkeTooltipProps, SilkeTooltipSize } from './silke-tooltip';
3
3
  import styles from './silke-tooltip.scss';
4
4
 
5
- interface SilkeDefinitionTooltipProps {
5
+ type SilkeDefinitionTooltipProps = {
6
6
  children: React.ReactNode;
7
7
  style?: React.CSSProperties;
8
8
  className?: string;
9
9
  show?: boolean;
10
+ size?: SilkeTooltipSize;
11
+ kind?: 'default' | 'info';
10
12
  tooltip: React.ReactNode;
11
- }
13
+ } & Omit<SilkeTooltipProps, 'children' | 'anchor' | 'show'>;
12
14
 
13
15
  /**
14
16
  * Wrap some text in this to show extra context
@@ -19,6 +21,9 @@ export function SilkeDefinitionTooltip({
19
21
  show,
20
22
  tooltip,
21
23
  style,
24
+ size,
25
+ anchorOrigin,
26
+ ...rest
22
27
  }: SilkeDefinitionTooltipProps) {
23
28
  const ref = useRef<HTMLElement>(null);
24
29
  const [isShowing, setShowing] = useState(show ?? false);
@@ -40,11 +45,14 @@ export function SilkeDefinitionTooltip({
40
45
 
41
46
  {ref && (
42
47
  <SilkeTooltip
48
+ {...rest}
43
49
  anchor={ref}
50
+ size={size || 'tiny'}
44
51
  show={show === undefined ? isShowing : show}
45
- hPos="left"
46
- tooltip={tooltip}
47
- />
52
+ anchorOrigin={anchorOrigin || 'bottom-right'}
53
+ >
54
+ {tooltip}
55
+ </SilkeTooltip>
48
56
  )}
49
57
  </>
50
58
  );
@@ -1,19 +1,19 @@
1
+ import { Keyboard, KeyboardEventCode } from '@vev/utils';
2
+ import { isString } from 'lodash';
1
3
  import React, { useEffect, useRef, useState } from 'react';
2
- import { SilkeTooltip } from './silke-tooltip';
4
+ import { SilkeBox } from '../silke-box';
3
5
  import { SilkeIcon, SilkeIcons } from '../silke-icon';
6
+ import { SilkeTooltip, SilkeTooltipProps } from './silke-tooltip';
4
7
  import styles from './silke-tooltip.scss';
5
- import { SilkeBox } from '../silke-box';
6
- import { isString } from 'lodash';
7
- import { Keyboard } from '@vev/utils';
8
8
 
9
- interface SilkeIconTooltipProps {
9
+ type SilkeIconTooltipProps = {
10
10
  icon?: SilkeIcons;
11
11
  tooltip: React.ReactNode;
12
- shortcut?: string[] | string;
12
+ shortcut?: KeyboardEventCode[] | KeyboardEventCode;
13
13
  show?: boolean;
14
14
  /** If interaction content in the tooltip then this should be set to true */
15
15
  interactive?: boolean;
16
- }
16
+ } & Omit<SilkeTooltipProps, 'children' | 'anchor' | 'show'>;
17
17
 
18
18
  /**
19
19
  * Shows an icon with a tooltip anchored to it
@@ -24,10 +24,14 @@ export function SilkeIconTooltip({
24
24
  shortcut,
25
25
  show,
26
26
  tooltip,
27
+ size,
28
+ ...rest
27
29
  }: SilkeIconTooltipProps) {
28
30
  const ref = useRef<HTMLElement | null>(null);
29
31
  const contentRef = useRef<HTMLElement | null>(null);
30
- const [isShowing, setShowing] = useState(show ?? false);
32
+ const [hoveringIcon, setHoveringIcon] = useState(show ?? false);
33
+ const [hoveringContent, setHoveringContent] = useState(false);
34
+
31
35
  /**
32
36
  * `shortcut`, if any, as an array
33
37
  */
@@ -43,21 +47,15 @@ export function SilkeIconTooltip({
43
47
  let timeout = 0;
44
48
  const handleMouseOver = () => {
45
49
  clearTimeout(timeout);
46
- setShowing(true);
50
+ setHoveringIcon(true);
47
51
  };
48
52
  const handleMouseOut = () => {
49
53
  clearTimeout(timeout);
50
- timeout = self.setTimeout(() => setShowing(false), interactive ? 400 : 1);
54
+ timeout = self.setTimeout(() => setHoveringIcon(false), interactive ? 400 : 1);
51
55
  };
52
56
 
53
- el.addEventListener('mouseover', handleMouseOver);
54
- el.addEventListener('mouseleave', handleMouseOut);
55
- const contentEl = contentRef.current;
56
- if (contentEl && interactive) {
57
- contentEl.addEventListener('mouseover', handleMouseOver);
58
- contentEl.addEventListener('mouseleave', handleMouseOut);
59
- }
60
-
57
+ el.addEventListener('mouseover', handleMouseOver, { passive: true });
58
+ el.addEventListener('mouseleave', handleMouseOut, { passive: true });
61
59
  return () => {
62
60
  el.removeEventListener('mouseover', handleMouseOver);
63
61
  el.removeEventListener('mouseleave', handleMouseOver);
@@ -66,34 +64,50 @@ export function SilkeIconTooltip({
66
64
  }, [ref, interactive]);
67
65
 
68
66
  useEffect(() => {
69
- if (show !== undefined) setShowing(show);
67
+ const contentEl = contentRef.current;
68
+ if (show && interactive && contentEl) {
69
+ const handleMouseOver = () => setHoveringContent(true);
70
+ const handleMouseOut = () => setHoveringContent(false);
71
+
72
+ contentEl.addEventListener('mouseover', handleMouseOver, { passive: true });
73
+ contentEl.addEventListener('mouseleave', handleMouseOut, { passive: true });
74
+
75
+ return () => {
76
+ contentEl.removeEventListener('mouseover', handleMouseOver);
77
+ contentEl.removeEventListener('mouseleave', handleMouseOut);
78
+ };
79
+ }
80
+ }, [show, interactive]);
81
+
82
+ useEffect(() => {
83
+ if (show !== undefined) setHoveringIcon(show);
70
84
  }, [show]);
71
85
 
72
86
  return (
73
87
  <>
74
- <span ref={ref} style={{ marginLeft: 16 }}>
88
+ <span ref={ref} style={{ marginLeft: 8 }}>
75
89
  <SilkeIcon icon={icon} />
76
90
  </span>
77
91
  <SilkeTooltip
92
+ {...rest}
78
93
  anchor={ref}
79
- kind="light"
80
- show={isShowing}
81
- tooltip={
82
- <SilkeBox gap="s" ref={contentRef}>
83
- {isString(tooltip) ? (
84
- <span dangerouslySetInnerHTML={{ __html: tooltip }} />
85
- ) : (
86
- <span>{tooltip}</span>
87
- )}
88
- <SilkeShortcuts shortcuts={shortcutArray} />
89
- </SilkeBox>
90
- }
91
- />
94
+ size={size || 'tiny'}
95
+ show={hoveringIcon || hoveringContent}
96
+ >
97
+ <SilkeBox gap="s" ref={contentRef} style={{ pointerEvents: interactive ? 'all' : 'none' }}>
98
+ {isString(tooltip) ? (
99
+ <span dangerouslySetInnerHTML={{ __html: tooltip }} />
100
+ ) : (
101
+ <span>{tooltip}</span>
102
+ )}
103
+ <SilkeShortcuts shortcuts={shortcutArray} />
104
+ </SilkeBox>
105
+ </SilkeTooltip>
92
106
  </>
93
107
  );
94
108
  }
95
109
 
96
- export const SilkeShortcuts = ({ shortcuts }: { shortcuts?: string[] }) =>
110
+ export const SilkeShortcuts = ({ shortcuts }: { shortcuts?: KeyboardEventCode[] }) =>
97
111
  shortcuts ? (
98
112
  <SilkeBox gap="s" style={{ display: 'inline' }}>
99
113
  {shortcuts.map((s, i) => (
@@ -12,7 +12,6 @@ type SilkeInteractiveTooltipStep = {
12
12
 
13
13
  interface SilkeInteractiveTooltipProps {
14
14
  anchor: PopoverAnchor;
15
- hPos?: TooltipHorizontalPosition;
16
15
  /**
17
16
  * If set, the last step will say 'Next', not 'Finish'
18
17
  */
@@ -30,7 +29,6 @@ interface SilkeInteractiveTooltipProps {
30
29
  */
31
30
  export function SilkeInteractiveTooltip({
32
31
  anchor,
33
- hPos,
34
32
  lastIsNotLast,
35
33
  onFinished,
36
34
  show,
@@ -85,5 +83,9 @@ export function SilkeInteractiveTooltip({
85
83
  </SilkeBox>
86
84
  );
87
85
 
88
- return <SilkeTooltip anchor={anchor} hPos={hPos} show={actuallyShow} tooltip={JustTheTip} />;
86
+ return (
87
+ <SilkeTooltip anchor={anchor} show={actuallyShow}>
88
+ {JustTheTip}
89
+ </SilkeTooltip>
90
+ );
89
91
  }
@@ -6,6 +6,36 @@
6
6
  const ref = React.useRef();
7
7
  const [isShowing, setShowing] = React.useState(true);
8
8
 
9
+ <>
10
+ <SilkeBox gap>
11
+ <SilkeButton
12
+ onClick={() => setShowing(!isShowing)}
13
+ label="Toggle tooltip"
14
+ />
15
+ <SilkeButton ref={ref} label="Nuclear launch" kind="danger" />
16
+ </SilkeBox>
17
+
18
+ <SilkeTooltip anchor={ref} show={isShowing}>
19
+ Tooltip on the bottom
20
+ </SilkeTooltip>
21
+ <SilkeTooltip anchor={ref} show={isShowing} anchorOrigin="top-center">
22
+ Tooltop on the top
23
+ </SilkeTooltip>
24
+ <SilkeTooltip anchor={ref} show={isShowing} anchorOrigin="center-right">
25
+ Tooltop on the right
26
+ </SilkeTooltip>
27
+ <SilkeTooltip anchor={ref} show={isShowing} anchorOrigin="center-left">
28
+ Tooltop on the left
29
+ </SilkeTooltip>
30
+ </>;
31
+ ```
32
+
33
+ ### Information tooltip
34
+
35
+ ```js
36
+ const ref = React.useRef();
37
+ const [isShowing, setShowing] = React.useState(true);
38
+
9
39
  <>
10
40
  <SilkeBox gap>
11
41
  <SilkeButton
@@ -16,10 +46,47 @@ const [isShowing, setShowing] = React.useState(true);
16
46
  </SilkeBox>
17
47
 
18
48
  <SilkeTooltip
49
+ kind="info"
50
+ image={ipsum.image()}
51
+ size="tiny"
19
52
  anchor={ref}
20
53
  show={isShowing}
21
- tooltip="Launches all nukes, beware of retaliation"
22
- />
54
+ >
55
+ Tooltip on the bottom
56
+ </SilkeTooltip>
57
+ <SilkeTooltip
58
+ kind="info"
59
+ size="small"
60
+ title="Tooltip title"
61
+ anchor={ref}
62
+ image={ipsum.image()}
63
+ show={isShowing}
64
+ anchorOrigin="top-center"
65
+ >
66
+ Tooltop on the top
67
+ </SilkeTooltip>
68
+ <SilkeTooltip
69
+ kind="info"
70
+ size="base"
71
+ image={ipsum.image()}
72
+ title="Tooltip title"
73
+ anchor={ref}
74
+ show={isShowing}
75
+ anchorOrigin="center-right"
76
+ >
77
+ Tooltop on the right
78
+ </SilkeTooltip>
79
+ <SilkeTooltip
80
+ kind="info"
81
+ size="large"
82
+ image={ipsum.image()}
83
+ title="Tooltip title"
84
+ anchor={ref}
85
+ show={isShowing}
86
+ anchorOrigin="center-left"
87
+ >
88
+ Tooltop on the left
89
+ </SilkeTooltip>
23
90
  </>;
24
91
  ```
25
92
 
@@ -1,59 +1,55 @@
1
- @use '../../variables' as *;
2
- .container {
3
- background: var(--color-neutral-low-medium);
4
- max-width: 256px;
5
- border-radius: 8px;
6
- filter:drop-shadow(0 4px 16px rgba(var(--color-neutral-low-pure-rgb), var(--opacity-level-light)))
7
- }
8
-
9
- .light {
10
- @extend .container;
1
+ @use "../../variables" as *;
11
2
 
12
- background: var(--color-neutral-high-pure);
13
- color: var(--color-neutral-low-pure);
14
- a{
15
- color: var(--color-neutral-low-pure);
16
- text-decoration: underline;
3
+ $border-color: rgba(
4
+ var(--color-neutral-60-rgb),
5
+ var(--opacity-level-light)
6
+ );
7
+ .root {
8
+ position: relative;
9
+ filter: var(--shadow-level-4);
10
+ svg {
11
+ position: absolute;
12
+ top: 0;
13
+ left: 0;
14
+ z-index: -1;
15
+ overflow: visible;
16
+ pointer-events: none;
17
17
  }
18
- }
19
18
 
20
- .arrow {
21
- position: absolute;
22
- top: 0;
23
- right: 50%;
24
- transform: translate(50%, calc(-100% + 0.5px)); // Need the plus "some" because of rounding or whatever. Will some times be one off.
25
-
26
- width: 12px;
27
- height: 6px;
28
-
29
- clip-path: polygon(0 100%, 50% 0, 100% 100%, 0 100%);
19
+ path {
20
+ stroke: $border-color;
21
+ stroke-width: 1px;
22
+ fill: var(--color-neutral-10);
23
+ }
30
24
  }
31
25
 
32
- .arrowDark {
33
- background: var(--color-neutral-low-medium);
26
+ .content {
27
+ font-size: 12px;
34
28
  }
35
-
36
- .arrowLight {
37
- background: var(--color-neutral-high-pure);
29
+ .default {
30
+ .content {
31
+ max-width: 256px;
32
+ padding: $space-xs $space-s;
33
+ line-height: #{$size-s - $space-xs * 2};
34
+ }
38
35
  }
39
36
 
40
- .leftArrow {
41
- @extend .arrow;
42
-
43
- right: unset;
44
- left: $space-m;
45
- transform: translate(0, calc(-100% + 0.5px));
37
+ .info {
38
+ .content {
39
+ padding: $space-s $space-m;
40
+ }
46
41
  }
47
42
 
48
- .rightArrow {
49
- @extend .leftArrow;
50
-
51
- left: unset;
52
- right: $space-m;
43
+ .img {
44
+ margin: -8px -8px 0 -8px;
45
+ width: calc(16px + 100%);
46
+ aspect-ratio: 4/3;
47
+ object-fit: cover;
48
+ object-position: center center;
53
49
  }
54
50
 
55
51
  .definitionTooltip {
56
- border-bottom: 1px dashed var(--color-brand-primary-soft);
52
+ border-bottom: 1px dotted var(--color-accent-40);
57
53
 
58
54
  &:hover {
59
55
  border-bottom-style: solid;
@@ -61,10 +57,39 @@
61
57
  }
62
58
 
63
59
  .shortcut {
64
- background: var(--color-neutral-low-pure);
65
- color: var(--color-neutral-high-pure);
66
- border: 1px solid var(--color-neutral-low-medium);
60
+ background: var(--color-neutral-0);
61
+ color: var(--color-neutral-100);
62
+ border: 1px solid var(--color-neutral-20);
67
63
  padding-left: 4px;
68
64
  padding-right: 4px;
69
65
  border-radius: 2px;
70
66
  }
67
+
68
+
69
+ .tiny{
70
+ width: 192px;
71
+ .img{
72
+ aspect-ratio: 192/120;
73
+ }
74
+ }
75
+
76
+ .small{
77
+ width: 256px;
78
+ .img{
79
+ aspect-ratio: 256/160;
80
+ }
81
+ }
82
+
83
+ .base{
84
+ width: 320px;
85
+ .img{
86
+ aspect-ratio: 320/200;
87
+ }
88
+ }
89
+
90
+ .large{
91
+ width: 384px;
92
+ .img{
93
+ aspect-ratio: 384/240;
94
+ }
95
+ }