Skip to content

Commit caac868

Browse files
committed
feat(app): add alt theme style
1 parent 6acb037 commit caac868

6 files changed

Lines changed: 53 additions & 19 deletions

File tree

apps/codeimage/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export function App() {
9090
tabIcon={tabIcon()?.content}
9191
showWatermark={terminal.showWatermark}
9292
opacity={terminal.opacity}
93+
alternativeTheme={terminal.alternativeTheme}
9394
>
9495
<CustomEditor />
9596
</DynamicTerminal>

apps/codeimage/src/components/Frame/Frame.css.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const handler = style([
4646
export const content = style({
4747
width: '100%',
4848
height: '100%',
49-
marginTop: '20px',
49+
marginTop: '10px',
5050
marginBottom: '40px',
5151
position: 'relative',
5252
});
@@ -198,23 +198,9 @@ export const presets = style({
198198
columnGap: themeVars.spacing['2'],
199199
});
200200

201-
export const presetsContainer = style({
201+
export const toolbar = style({
202202
height: '28px',
203203
width: 'auto',
204-
borderRadius: themeVars.borderRadius.lg,
205204
display: 'flex',
206-
alignItems: 'center',
207-
backgroundColor: darkGrayScale.gray5,
208-
columnGap: '8px',
209-
color: darkGrayScale.gray11,
210-
paddingRight: themeVars.spacing['4'],
211-
});
212-
213-
export const presetsBox = style({
214-
display: 'block',
215-
height: '28px',
216-
width: '28px',
217-
borderRadius: themeVars.borderRadius.lg,
218-
background: backgroundColorVar,
219-
marginRight: themeVars.spacing['1'],
205+
justifyContent: 'flex-end',
220206
});

apps/codeimage/src/components/Frame/FrameHandler.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import {focusedEditor$} from '@codeimage/store/editor';
22
import {onCopyToClipboard} from '@codeimage/store/effects/onCopyToClipboard';
3-
import {Box} from '@codeimage/ui';
3+
import {
4+
isAlternativeTheme$,
5+
setAlternativeTheme,
6+
toggleAlternativeTheme,
7+
} from '@codeimage/store/terminal';
8+
import {Box, Button} from '@codeimage/ui';
49
import {dispatch} from '@ngneat/effects';
510
import {assignInlineVars} from '@vanilla-extract/dynamic';
611
import {WithRef} from 'solid-headless/dist/types/utils/dynamic-prop';
@@ -42,6 +47,8 @@ export function FrameHandler(
4247

4348
const ratio = 0.1;
4449

50+
const isAlternative = from(isAlternativeTheme$);
51+
4552
createEffect(
4653
on([handlerRef], ([frame]) => {
4754
if (modality === 'mobile') {
@@ -77,6 +84,20 @@ export function FrameHandler(
7784
}
7885
ref={setHandlerRef}
7986
>
87+
<div class={styles.toolbar}>
88+
<Button
89+
variant={'solid'}
90+
size={'xs'}
91+
theme={'secondary'}
92+
style={{height: 'auto'}}
93+
onClick={() => toggleAlternativeTheme()}
94+
>
95+
{isAlternative()
96+
? 'Apply default theme'
97+
: 'Apply alternative theme'}
98+
</Button>
99+
</div>
100+
80101
<div
81102
class={styles.content}
82103
ref={createRef<'div'>(props, e => {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ export interface TerminalHostProps extends BaseTerminalProps {
2727

2828
export const TerminalHost: FlowComponent<TerminalHostProps> = props => {
2929
const background = () => {
30+
if (props.alternativeTheme) {
31+
return `rgba(${styles.terminalVars.headerColor}, .70)`;
32+
}
3033
const opacity = (props.opacity ?? 100) / 100;
3134
if (props.opacity !== 100) {
3235
return `rgba(0,0,0, ${opacity})`;
3336
}
34-
return rgba(props.background, opacity);
37+
return props.background;
3538
};
3639

3740
return (

apps/codeimage/src/components/Terminal/terminal.css.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const [terminalTheme, terminalVars] = createTheme({
1010
textColor: themeVars.backgroundColor.gray['800'],
1111
boxShadow: themeVars.boxShadow.lg,
1212
tabDelta: '10px',
13+
headerColor: '0, 0, 0',
1314
});
1415

1516
export const wrapper = style([
@@ -22,6 +23,18 @@ export const wrapper = style([
2223
borderRadius: terminalVars.radius,
2324
boxShadow: terminalVars.boxShadow,
2425
transition: 'box-shadow .2s, border-radius .2s',
26+
selectors: {
27+
'&[data-theme-mode=light]': {
28+
vars: {
29+
[terminalVars.headerColor]: `255, 255, 255`,
30+
},
31+
},
32+
'&[data-theme-mode=dark] &': {
33+
vars: {
34+
[terminalVars.headerColor]: `0, 0, 0`,
35+
},
36+
},
37+
},
2538
},
2639
]);
2740

apps/codeimage/src/state/terminal.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface TerminalState {
2222
readonly showWatermark: boolean;
2323
readonly showGlassReflection: boolean;
2424
readonly opacity: number;
25+
readonly alternativeTheme: boolean;
2526
}
2627

2728
const initialState: TerminalState = {
@@ -39,6 +40,7 @@ const initialState: TerminalState = {
3940
showWatermark: true,
4041
showGlassReflection: false,
4142
opacity: 100,
43+
alternativeTheme: false,
4244
};
4345

4446
const store = createStore(
@@ -67,6 +69,10 @@ export function toggleShowHeader() {
6769
store.update(setProp('showHeader', showHeader => !showHeader));
6870
}
6971

72+
export function toggleAlternativeTheme() {
73+
store.update(setProp('alternativeTheme', alternative => !alternative));
74+
}
75+
7076
export function toggleWatermark() {
7177
store.update(setProp('showWatermark', showWatermark => !showWatermark));
7278
}
@@ -82,3 +88,7 @@ export function setTabName(tabName: string) {
8288
export const terminal$ = store.pipe(distinctUntilChanged(shallow));
8389

8490
export const tabName$ = store.pipe(select(state => state.tabName));
91+
92+
export const isAlternativeTheme$ = store.pipe(
93+
select(state => state.alternativeTheme),
94+
);

0 commit comments

Comments
 (0)