Skip to content

Commit

Permalink
Dynamically swap themes for asciinema (#931)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elsie19 authored Jul 29, 2024
1 parent d461277 commit 32a6236
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions client/src/components/AsciinemaFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ const AsciinemaFrame: FC<{
id: string
autoplay?: boolean
loop?: boolean
}> = ({ id, autoplay, loop }) => (
dark?: boolean
}> = ({ id, autoplay, loop, dark }) => (
<iframe
src={`https://asciinema.org/a/${id}/iframe?theme=monokai&autoplay=${
src={`https://asciinema.org/a/${id}/iframe?theme=${dark ? 'solarized-light' : 'monokai'}&autoplay=${
autoplay ? 1 : 0
}&loop=${loop ? 1 : 0}&speed=0.75`}
id={`asciicast-iframe-${id}`}
Expand Down
11 changes: 9 additions & 2 deletions client/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Stack,
Text,
useBreakpointValue,
useColorMode,
} from '@chakra-ui/react'
import { FC } from 'react'
import Card from '../components/Card'
Expand All @@ -18,6 +19,7 @@ import { Trans, useTranslation } from 'react-i18next'

const Home: FC = () => {
const { t } = useTranslation()
const { colorMode } = useColorMode()
return (
<>
<Helmet>
Expand Down Expand Up @@ -98,12 +100,17 @@ const Home: FC = () => {
<Heading size={'lg'} mb='3' mt='10'>
{t('home.showcase.title')}
</Heading>
<AsciinemaFrame autoplay loop id='538264' />
<AsciinemaFrame
autoplay
loop
id='538264'
dark={colorMode === 'light'}
/>

<Heading size={'lg'} mb='3'>
{t('home.showcase.packageSearch')}
</Heading>
<AsciinemaFrame id='538265' />
<AsciinemaFrame id='538265' dark={colorMode === 'light'} />

<Stack justify='center'>
<Image
Expand Down

0 comments on commit 32a6236

Please sign in to comment.