@brillout/docpress 0.17.2 → 0.17.3

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.
@@ -1,3 +1,10 @@
1
+ .choice-group-container.always-show {
2
+ .choice-group__selects,
3
+ .copy-button {
4
+ opacity: 1 !important;
5
+ }
6
+ }
7
+
1
8
  .choice-group-container {
2
9
  position: relative;
3
10
 
@@ -18,6 +25,12 @@
18
25
  gap: 2px;
19
26
  top: var(--top-position);
20
27
  right: 42px;
28
+ opacity: 0;
29
+ transition: opacity 200ms ease-in-out;
30
+
31
+ &:hover {
32
+ opacity: 1;
33
+ }
21
34
  }
22
35
 
23
36
  .choice-select__list {
@@ -143,6 +156,10 @@
143
156
  * https://github.com/brillout/docpress/blob/08b63e867c4c052479e19a6943ca5535b2762d02/src/css/code/block.css#L40-L56
144
157
  */
145
158
  @media not all and (hover: hover) and (pointer: fine) {
159
+ .choice-group__selects,
160
+ .copy-button {
161
+ opacity: 1 !important;
162
+ }
146
163
  .choice-select__option {
147
164
  padding: 5px;
148
165
  }
@@ -256,6 +273,18 @@
256
273
  }
257
274
  }
258
275
 
276
+ .choice-group-container:has(.choice-group__selects:hover) .copy-button {
277
+ opacity: 1;
278
+ }
279
+
280
+ .choice-group:has(.choice:hover) .copy-button {
281
+ opacity: 1;
282
+ }
283
+
284
+ .choice-group:has(.choice:hover) ~ .choice-group__selects {
285
+ opacity: 1;
286
+ }
287
+
259
288
  .choice-group {
260
289
  /* choice visibility logic */
261
290
  select:has(option:nth-of-type(1):not(:checked)) ~ .choice:nth-of-type(1),
@@ -14,8 +14,10 @@ function ChoiceGroupContainer({
14
14
  choiceGroupAll,
15
15
  }: { children: React.ReactNode; choiceGroupAll: ChoiceGroupWithParent[] }) {
16
16
  const renderCustomSelect = (choiceGroupAll ?? []).some((choiceGroup) => choiceGroup.lvl === 0 && !choiceGroup.hidden)
17
+ const alwaysShow = (choiceGroupAll ?? []).some((choiceGroup) => renderCustomSelect && !!choiceGroup.alwaysShow)
18
+
17
19
  return (
18
- <div className="choice-group-container">
20
+ <div className={cls(['choice-group-container', alwaysShow && 'always-show'])}>
19
21
  {children}
20
22
  {renderCustomSelect && (
21
23
  <div className={`choice-group__selects`}>
@@ -149,5 +151,7 @@ function CustomSelect({ choiceGroup }: { choiceGroup: ChoiceGroupWithParent }) {
149
151
  } else {
150
152
  setSelectedChoice(choice)
151
153
  }
154
+
155
+ if (lastPointerType.current !== 'mouse') setExpanded(false)
152
156
  }
153
157
  }
@@ -14,6 +14,12 @@ pre {
14
14
  position: relative;
15
15
  }
16
16
 
17
+ &:hover {
18
+ .copy-button {
19
+ opacity: 1;
20
+ }
21
+ }
22
+
17
23
  .copy-button {
18
24
  position: absolute !important;
19
25
  top: 10px;
@@ -22,7 +28,8 @@ pre {
22
28
  height: 25px;
23
29
  width: 30px;
24
30
  background-color: #f7f7f7;
25
- transition: background-color 0.4s ease-in-out;
31
+ opacity: 0;
32
+ transition: background-color 0.4s ease-in-out, opacity 200ms ease-in-out;
26
33
 
27
34
  &:not(:hover) {
28
35
  background-color: #eee;
@@ -81,4 +81,4 @@
81
81
 
82
82
  .choice-tabs__tab:focus {
83
83
  outline: none;
84
- }
84
+ }
@@ -47,6 +47,7 @@ const CHOICES_BUILT_IN: NonNullable<Config['choices']> = {
47
47
  { name: 'Yarn', icon: YARN_ICON, iconStyle: { height: '12px' } },
48
48
  ],
49
49
  default: 'npm',
50
+ alwaysShow: true,
50
51
  },
51
52
  }
52
53
 
@@ -160,6 +161,7 @@ function resolveChoiceGroupNodes(choiceNodes: ChoiceNode[]) {
160
161
  name: groupName,
161
162
  ...group,
162
163
  emptyChoices,
164
+ alwaysShow: !!group.alwaysShow,
163
165
  }
164
166
 
165
167
  const mergedChoiceNodes: ChoiceNode[] = choiceGroup.choices.map((choice) => {
@@ -35,6 +35,7 @@ const CHOICES_BUILT_IN = {
35
35
  { name: 'Yarn', icon: YARN_ICON, iconStyle: { height: '12px' } },
36
36
  ],
37
37
  default: 'npm',
38
+ alwaysShow: true,
38
39
  },
39
40
  };
40
41
  function generateChoiceGroupCode(choiceNodes, parent, hide = false) {
@@ -130,6 +131,7 @@ function resolveChoiceGroupNodes(choiceNodes) {
130
131
  name: groupName,
131
132
  ...group,
132
133
  emptyChoices,
134
+ alwaysShow: !!group.alwaysShow,
133
135
  };
134
136
  const mergedChoiceNodes = choiceGroup.choices.map((choice) => {
135
137
  const node = choiceNodes.find((node) => node.choiceValue === choice.name);
@@ -69,4 +69,10 @@ type ChoiceItem = {
69
69
  type Choice = {
70
70
  choices: (string | ChoiceItem)[];
71
71
  default: string;
72
+ /**
73
+ * Whether to always show the dropdown.
74
+ *
75
+ * @default false
76
+ */
77
+ alwaysShow?: boolean;
72
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.17.2",
3
+ "version": "0.17.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
package/types/Config.ts CHANGED
@@ -85,4 +85,10 @@ type ChoiceItem = {
85
85
  type Choice = {
86
86
  choices: (string | ChoiceItem)[]
87
87
  default: string
88
+ /**
89
+ * Whether to always show the dropdown.
90
+ *
91
+ * @default false
92
+ */
93
+ alwaysShow?: boolean
88
94
  }