Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): allow zero padding #625

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tame-deers-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@codeimage/app': minor
---

feat: allow zero padding
34 changes: 26 additions & 8 deletions apps/codeimage/src/components/PropertyEditor/FrameStyleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,24 @@ import {CustomColorPicker} from './controls/ColorPicker/CustomColorPicker';
import {PanelHeader} from './PanelHeader';
import {PanelRow, TwoColumnPanelRow} from './PanelRow';
import {SuspenseEditorItem} from './SuspenseEditorItem';
import {Select, createSelectOptions} from '@codeui/kit';

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

const paddingOptions = createSelectOptions(
editorPadding.map(padding => ({
label: padding.label,
value: padding.value,
})),
{
key: 'label',
valueKey: 'value',
},
);

return (
<>
<PanelHeader label={t('frame.frame')} />
Expand All @@ -27,16 +39,22 @@ export const FrameStyleForm: ParentComponent = () => {
<SuspenseEditorItem
fallback={<SkeletonLine width={'100%'} height={'26px'} />}
>
<SegmentedField
adapt
<Select
disallowEmptySelection
{...paddingOptions.props()}
{...paddingOptions.controlled(
() => String(frame.store.padding),
padding => {
if (typeof padding === 'undefined') {
return;
}
frame.setPadding(Number(padding));
},
)}
options={paddingOptions.options()}
aria-label={'Padding'}
id={'paddingField'}
size={'xs'}
value={frame.store.padding}
onChange={frame.setPadding}
items={editorPadding.map(padding => ({
label: padding.toString(),
value: padding,
}))}
/>
</SuspenseEditorItem>
</TwoColumnPanelRow>
Expand Down
3 changes: 3 additions & 0 deletions apps/codeimage/src/components/Terminal/TerminalHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {FlowComponent} from 'solid-js';
import {TerminalGlassReflection} from './GlassReflection/TerminalGlassReflection';
import {createTabTheme} from './Tabs/createTabTheme';
import * as styles from './terminal.css';
import {getFrameState} from '@codeimage/store/editor/frame';

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

const background = () => {
if (props.alternativeTheme) {
Expand Down Expand Up @@ -62,6 +64,7 @@ export const TerminalHost: FlowComponent<TerminalHostProps> = props => {
tabTheme().activeTabBackground ?? '',
[styles.terminalVars.tabAccentInactiveBackground]:
tabTheme().inactiveTabBackground ?? '',
[styles.terminalVars.radius]: frameState.padding === 0 ? 0 : undefined,
...(props.style ?? {}),
})}
>
Expand Down
8 changes: 7 additions & 1 deletion apps/codeimage/src/core/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ export const [appEnvironment] = createConfiguration({
locales: SUPPORTED_LOCALES,
themes: [],
languages: [],
editorPadding: [16, 32, 64, 128],
editorPadding: [
{label: '0', value: "0"},
{label: '16', value: "16"},
{label: '32', value: "32"},
{label: '64', value: "64"},
{label: '128', value: "128"},
],
editorRadius: [
{label: '0', value: 0},
{label: '8', value: 8},
Expand Down
6 changes: 4 additions & 2 deletions apps/codeimage/src/state/editor/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ const frameState = defineStore(() => getInitialFrameState())
.hold(store.commands.setNextPadding, (_, {state}) => {
const availablePadding = appEnvironment.editorPadding;
const padding = state.padding;
const currentIndex = appEnvironment.editorPadding.indexOf(padding);
const currentIndex = appEnvironment.editorPadding.findIndex(
item => Number(item.value) === padding,
);
const next = (currentIndex + 1) % availablePadding.length;
return {...state, padding: availablePadding[next]};
return {...state, padding: Number(availablePadding[next].value)};
})
.hold(store.commands.setFromPreset, presetData => {
store.set(state => ({...state, ...presetData}));
Expand Down
Loading