@brillout/docpress 0.17.1 → 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.
- package/code-blocks/components/ChoiceGroup.css +74 -0
- package/code-blocks/components/ChoiceGroup.tsx +5 -1
- package/code-blocks/components/Pre.css +8 -1
- package/code-blocks/components/Tabs.css +1 -1
- package/code-blocks/utils/generateChoiceGroupCode.ts +2 -0
- package/dist/code-blocks/utils/generateChoiceGroupCode.js +2 -0
- package/dist/types/Config.d.ts +6 -0
- package/package.json +1 -1
- package/types/Config.ts +6 -0
|
@@ -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 {
|
|
@@ -139,6 +152,55 @@
|
|
|
139
152
|
display: none !important;
|
|
140
153
|
}
|
|
141
154
|
|
|
155
|
+
/* Keep these breakpoints in sync with:
|
|
156
|
+
* https://github.com/brillout/docpress/blob/08b63e867c4c052479e19a6943ca5535b2762d02/src/css/code/block.css#L40-L56
|
|
157
|
+
*/
|
|
158
|
+
@media not all and (hover: hover) and (pointer: fine) {
|
|
159
|
+
.choice-group__selects,
|
|
160
|
+
.copy-button {
|
|
161
|
+
opacity: 1 !important;
|
|
162
|
+
}
|
|
163
|
+
.choice-select__option {
|
|
164
|
+
padding: 5px;
|
|
165
|
+
}
|
|
166
|
+
@container container-viewport (max-width: 620px) {
|
|
167
|
+
.choice-select__option-label {
|
|
168
|
+
font-size: 12px !important;
|
|
169
|
+
}
|
|
170
|
+
.choice-select__option-icon {
|
|
171
|
+
width: 13px !important;
|
|
172
|
+
}
|
|
173
|
+
.choice-select__option-content img {
|
|
174
|
+
width: 11.5px !important;
|
|
175
|
+
height: 11.5px !important;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
@container container-viewport (max-width: 550px) {
|
|
179
|
+
.choice-select__option-label {
|
|
180
|
+
font-size: 11px !important;
|
|
181
|
+
}
|
|
182
|
+
.choice-select__option-icon {
|
|
183
|
+
width: 12px !important;
|
|
184
|
+
}
|
|
185
|
+
.choice-select__option-content img {
|
|
186
|
+
width: 11px !important;
|
|
187
|
+
height: 11px !important;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
@container container-viewport (max-width: 450px) {
|
|
191
|
+
.choice-select__option-label {
|
|
192
|
+
font-size: 10px !important;
|
|
193
|
+
}
|
|
194
|
+
.choice-select__option-icon {
|
|
195
|
+
width: 11px !important;
|
|
196
|
+
}
|
|
197
|
+
.choice-select__option-content img {
|
|
198
|
+
width: 10px !important;
|
|
199
|
+
height: 10px !important;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
142
204
|
.choice-select__list:has(.choice-select__option:nth-of-type(1) .choice-select__radio:checked) {
|
|
143
205
|
top: 0;
|
|
144
206
|
clip-path: inset(
|
|
@@ -211,6 +273,18 @@
|
|
|
211
273
|
}
|
|
212
274
|
}
|
|
213
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
|
+
|
|
214
288
|
.choice-group {
|
|
215
289
|
/* choice visibility logic */
|
|
216
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=
|
|
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
|
-
|
|
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;
|
|
@@ -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);
|
package/dist/types/Config.d.ts
CHANGED
package/package.json
CHANGED