Skip to content

Commit

Permalink
Merge pull request #134 from glassmonkey/extend-switch
Browse files Browse the repository at this point in the history
Extend switch
  • Loading branch information
glassmonkey authored Feb 5, 2024
2 parents a3b3ffd + 7290cca commit 8b96184
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
16 changes: 15 additions & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Text,
Link,
Center,
Button,
Button, Switch, useColorMode,
} from '@chakra-ui/react';
import { useSearchParams } from 'react-router-dom';
import * as lzstring from 'lz-string';
Expand All @@ -34,6 +34,8 @@ export default function App() {
const currentVersion =
asVersion(searchParams.get('v')) ?? '8.3';

const { colorMode, toggleColorMode } = useColorMode();

const currentFormat = searchParams.get('f') as Format ?? "html";

function updateVersion(v: Version) {
Expand Down Expand Up @@ -90,6 +92,7 @@ export default function App() {
setHistory(code, version, format);
}


return (
<main style={{ margin: '16px' }}>
<Flex marginTop="8px" marginBottom="8px" gap="16px">
Expand Down Expand Up @@ -144,6 +147,17 @@ export default function App() {
onChange={updateVersion}
version={currentVersion}
/>
<Flex direction="row" gap={"8px"} alignItems={"center"}>
<Text fontSize="xs">UI Theme:</Text>
<Switch
variant="colormodeSwitcher"
size="lg"
fontSize="lg"
isChecked={ colorMode === "light" }
onChange={toggleColorMode}
mr={2}
/>
</Flex>
<SelectFormat format={currentFormat} updateFormat={updateFormat}/>
</Flex>
</Flex>
Expand Down
13 changes: 1 addition & 12 deletions src/header.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import { Heading, Text, Flex, Center, Switch, useColorMode } from '@chakra-ui/react';
import { Heading, Text, Flex, Center } from '@chakra-ui/react';
import * as React from 'react';

export default function Header() {

const { colorMode, toggleColorMode } = useColorMode();

return (
<Flex gap="8px" direction="column">
<Flex justify="space-between">
<Heading as="h1">PHP Playground</Heading>
<Switch
variant="colormodeswitcher"
size="lg"
fontSize="lg"
isChecked={ colorMode === "light" }
onChange={toggleColorMode}
mr={2}
/>
</Flex>
<Text as="p">
PHP Playground let you to execute basic PHP code in real time
Expand Down
4 changes: 2 additions & 2 deletions src/switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function extendSwitchTheme() {

const template = 'data:image/svg+xml;utf8,$';

const colormodeswitcher = definePartsStyle({
const colormodeSwitcher = definePartsStyle({
track: {
background: "#f1bf5a", // yellow
_dark: {
Expand All @@ -36,7 +36,7 @@ function extendSwitchTheme() {
}
});

return defineMultiStyleConfig({ variants: { colormodeswitcher } });
return defineMultiStyleConfig({ variants: { colormodeSwitcher } });
}

export const switchTheme = extendSwitchTheme();

0 comments on commit 8b96184

Please sign in to comment.