conditional rendering based on file type

This commit is contained in:
Valtteri Karesto
2022-08-17 21:06:01 +03:00
parent 33019835ea
commit b7c48c81a4

View File

@@ -159,7 +159,8 @@ const Home: NextPage = () => {
> >
<main style={{ display: 'flex', flex: 1, position: 'relative' }}> <main style={{ display: 'flex', flex: 1, position: 'relative' }}>
<HooksEditor /> <HooksEditor />
{snap.files[snap.active]?.name?.split('.')?.[1]?.toLowerCase() === 'c' && ( {(snap.files[snap.active]?.name?.split('.')?.[1]?.toLowerCase() === 'c' ||
snap.files[snap.active]?.name?.split('.')?.[1]?.toLowerCase() === 'ts') && (
<Hotkeys <Hotkeys
keyName="command+b,ctrl+b" keyName="command+b,ctrl+b"
onKeyDown={() => !snap.compiling && snap.files.length && compileCode(snap.active)} onKeyDown={() => !snap.compiling && snap.files.length && compileCode(snap.active)}
@@ -185,11 +186,13 @@ const Home: NextPage = () => {
<Play weight="bold" size="16px" /> <Play weight="bold" size="16px" />
Compile to Wasm Compile to Wasm
</Button> </Button>
<Popover content={<CompilerSettings />}> {snap.files[snap.active].language === 'c' && (
<Button variant="primary" css={{ px: '10px' }}> <Popover content={<CompilerSettings />}>
<Gear size="16px" /> <Button variant="primary" css={{ px: '10px' }}>
</Button> <Gear size="16px" />
</Popover> </Button>
</Popover>
)}
</Flex> </Flex>
</Hotkeys> </Hotkeys>
)} )}