Skip to content

Commit 462a0d8

Browse files
committed
refactor(components): Code 中的 toolbar 添加了打印和扩展按钮
1 parent 48fbf46 commit 462a0d8

5 files changed

Lines changed: 39 additions & 30 deletions

File tree

apps/docs/src/components/stages/stage.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,14 @@ export default function Stage(props: Props): JSX.Element {
113113

114114
<Show when={props.source}>
115115
{s => (
116-
<Code.Root wrap ln={0} lang="tsx" class={styles.code} style={{ height: codeHeight() }}>
116+
<Code.Root
117+
wrap
118+
ln={0}
119+
lang="tsx"
120+
class={styles.code}
121+
style={{ height: codeHeight() }}
122+
decorates={['toolbar']}
123+
>
117124
{s()}
118125
</Code.Root>
119126
)}

apps/docs/src/components/stages/style.module.css

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,33 +106,33 @@
106106
}
107107

108108
.code {
109-
@apply border-transparent rounded-none! flex-1 w-1/2;
109+
@apply bg-palette-2-bg! flex-1 w-1/2;
110110
}
111+
}
111112

112-
.stage.vertical {
113-
@apply flex-col items-stretch! justify-stretch!;
113+
.stage.vertical {
114+
@apply flex-col items-stretch! justify-stretch!;
114115

115-
.demo {
116-
@apply w-full max-w-full;
117-
}
116+
.demo {
117+
@apply w-full max-w-full;
118+
}
118119

119-
.code {
120-
@apply w-full;
121-
}
120+
.code {
121+
@apply w-full;
122122
}
123+
}
123124

124-
.stage.auto {
125-
@apply @max-3xl/stages:flex-col! @max-3xl/stages:justify-start! @max-3xl/stages:items-start!;
125+
.stage.auto {
126+
@apply @max-3xl/stages:flex-col! @max-3xl/stages:justify-start! @max-3xl/stages:items-start!;
126127

127-
.demo {
128-
@apply h-full min-h-fit w-1/2;
129-
@apply @max-3xl/stages:w-full!;
130-
}
128+
.demo {
129+
@apply h-full min-h-fit w-1/2;
130+
@apply @max-3xl/stages:w-full!;
131+
}
131132

132-
.code {
133-
@apply w-1/2 overflow-y-auto;
134-
@apply @max-3xl/stages:w-full! @max-3xl/stages:flex-none;
135-
}
133+
.code {
134+
@apply w-1/2 overflow-y-auto;
135+
@apply @max-3xl/stages:w-full! @max-3xl/stages:flex-none;
136136
}
137137
}
138138
}

packages/components/src/code/decorate.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { render } from 'solid-js/web';
77
import IconDown from '~icons/material-symbols/keyboard-arrow-down-rounded';
88
import IconUp from '~icons/material-symbols/keyboard-arrow-up-rounded';
99

10-
import { Button, ToggleButton } from '@components/button';
10+
import { Button, PrintButton, ToggleButton } from '@components/button';
1111
import { ClipboardAPI } from '@components/clipboard';
1212
import styles from './style.module.css';
1313

@@ -134,6 +134,10 @@ registerDecorate('toolbar', pre => {
134134
<ClipboardAPI.Root ref={el => (clipboardRef = el)} />
135135
</Button.Root>
136136

137+
<ToggleButton.FitScreen kind='flat' class={styles.btn} container={pre} />
138+
139+
<PrintButton.Root kind='flat' class={styles.btn} element={() => pre} />
140+
137141
<ToggleButton.Root
138142
off={<IconUp />}
139143
on={<IconDown />}

packages/components/src/divider/root.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ export type Props = ParentProps<
1414
/**
1515
* 如果存在文字,表示文字的位置,否则该值无意义。
1616
*
17-
* @remarks
18-
* 在 children 不为空的情况下,如果未指定 pos,会初始化 'start'。
19-
*
2017
* @reactive
18+
* @defaultValue 'start'
2119
*/
2220
pos?: 'start' | 'center' | 'end';
2321

@@ -69,9 +67,9 @@ export function Root(props: Props): JSX.Element {
6967
props.palette,
7068
{
7169
[styles.vertical]: props.layout !== 'horizontal',
72-
[styles[`pos-${props.children ? (props.pos ?? 'none') : 'none'}`]]: true,
70+
[styles[`pos-${props.children ? props.pos : 'none'}`]]: true,
71+
[styles.divider]: true,
7372
},
74-
styles.divider,
7573
props.class,
7674
)}
7775
>

packages/components/src/divider/style.module.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
@layer components {
1010
.divider {
11-
@apply flex items-center justify-center text-palette-fg whitespace-nowrap w-full h-[1px];
11+
@apply flex items-center justify-center text-palette-fg whitespace-nowrap w-full h-px;
1212
}
1313

1414
.divider::before,
1515
.divider::after {
16-
@apply w-full grow-1 h-[1px] bg-palette-bg-low;
16+
@apply w-full grow h-px bg-palette-bg-low;
1717
}
1818

1919
.divider.pos-start::after,
@@ -43,12 +43,12 @@
4343
/*************************** vertical ********************************/
4444

4545
.divider.vertical {
46-
@apply flex-col h-full w-[1px];
46+
@apply flex-col h-full w-px;
4747
}
4848

4949
.divider.vertical::before,
5050
.divider.vertical::after {
51-
@apply h-full grow-1 w-[1px];
51+
@apply h-full grow w-px;
5252
}
5353

5454
.divider.vertical.pos-start::after,

0 commit comments

Comments
 (0)