Skip to content

Commit 29df7d7

Browse files
feat(app): allow zero padding
1 parent d3bcdac commit 29df7d7

File tree

5 files changed

+45
-11
lines changed

5 files changed

+45
-11
lines changed

.changeset/tame-deers-whisper.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@codeimage/app': minor
3+
---
4+
5+
feat: allow zero padding

apps/codeimage/src/components/PropertyEditor/FrameStyleForm.tsx

+26-8
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,24 @@ import {CustomColorPicker} from './controls/ColorPicker/CustomColorPicker';
1212
import {PanelHeader} from './PanelHeader';
1313
import {PanelRow, TwoColumnPanelRow} from './PanelRow';
1414
import {SuspenseEditorItem} from './SuspenseEditorItem';
15+
import {Select, createSelectOptions} from '@codeui/kit';
1516

1617
export const FrameStyleForm: ParentComponent = () => {
1718
const [t] = useI18n<AppLocaleEntries>();
1819
const {editorPadding, editorRadius} = appEnvironment;
1920
const frame = getFrameState();
2021

22+
const paddingOptions = createSelectOptions(
23+
editorPadding.map(padding => ({
24+
label: padding.label,
25+
value: padding.value,
26+
})),
27+
{
28+
key: 'label',
29+
valueKey: 'value',
30+
},
31+
);
32+
2133
return (
2234
<>
2335
<PanelHeader label={t('frame.frame')} />
@@ -27,16 +39,22 @@ export const FrameStyleForm: ParentComponent = () => {
2739
<SuspenseEditorItem
2840
fallback={<SkeletonLine width={'100%'} height={'26px'} />}
2941
>
30-
<SegmentedField
31-
adapt
42+
<Select
43+
disallowEmptySelection
44+
{...paddingOptions.props()}
45+
{...paddingOptions.controlled(
46+
() => String(frame.store.padding),
47+
padding => {
48+
if (typeof padding === 'undefined') {
49+
return;
50+
}
51+
frame.setPadding(Number(padding));
52+
},
53+
)}
54+
options={paddingOptions.options()}
55+
aria-label={'Padding'}
3256
id={'paddingField'}
3357
size={'xs'}
34-
value={frame.store.padding}
35-
onChange={frame.setPadding}
36-
items={editorPadding.map(padding => ({
37-
label: padding.toString(),
38-
value: padding,
39-
}))}
4058
/>
4159
</SuspenseEditorItem>
4260
</TwoColumnPanelRow>

apps/codeimage/src/components/Terminal/TerminalHost.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {FlowComponent} from 'solid-js';
88
import {TerminalGlassReflection} from './GlassReflection/TerminalGlassReflection';
99
import {createTabTheme} from './Tabs/createTabTheme';
1010
import * as styles from './terminal.css';
11+
import {getFrameState} from '@codeimage/store/editor/frame';
1112

1213
export interface BaseTerminalProps
1314
extends Omit<TerminalState, 'type'>,
@@ -30,6 +31,7 @@ export interface TerminalHostProps extends BaseTerminalProps {
3031
export const TerminalHost: FlowComponent<TerminalHostProps> = props => {
3132
const tabTheme = createTabTheme(() => props.themeId);
3233
const darkMode = () => tabTheme().darkMode;
34+
const frameState = getFrameState().store;
3335

3436
const background = () => {
3537
if (props.alternativeTheme) {
@@ -62,6 +64,7 @@ export const TerminalHost: FlowComponent<TerminalHostProps> = props => {
6264
tabTheme().activeTabBackground ?? '',
6365
[styles.terminalVars.tabAccentInactiveBackground]:
6466
tabTheme().inactiveTabBackground ?? '',
67+
[styles.terminalVars.radius]: frameState.padding === 0 ? 0 : undefined,
6568
...(props.style ?? {}),
6669
})}
6770
>

apps/codeimage/src/core/configuration.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ export const [appEnvironment] = createConfiguration({
77
locales: SUPPORTED_LOCALES,
88
themes: [],
99
languages: [],
10-
editorPadding: [16, 32, 64, 128],
10+
editorPadding: [
11+
{label: '0', value: "0"},
12+
{label: '16', value: "16"},
13+
{label: '32', value: "32"},
14+
{label: '64', value: "64"},
15+
{label: '128', value: "128"},
16+
],
1117
editorRadius: [
1218
{label: '0', value: 0},
1319
{label: '8', value: 8},

apps/codeimage/src/state/editor/frame.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ const frameState = defineStore(() => getInitialFrameState())
8686
.hold(store.commands.setNextPadding, (_, {state}) => {
8787
const availablePadding = appEnvironment.editorPadding;
8888
const padding = state.padding;
89-
const currentIndex = appEnvironment.editorPadding.indexOf(padding);
89+
const currentIndex = appEnvironment.editorPadding.findIndex(
90+
item => Number(item.value) === padding,
91+
);
9092
const next = (currentIndex + 1) % availablePadding.length;
91-
return {...state, padding: availablePadding[next]};
93+
return {...state, padding: Number(availablePadding[next].value)};
9294
})
9395
.hold(store.commands.setFromPreset, presetData => {
9496
store.set(state => ({...state, ...presetData}));

0 commit comments

Comments
 (0)