Skip to content

Commit

Permalink
Sketch dropdown before merging main into this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
cmhhelgeson committed Feb 28, 2024
1 parent 970f069 commit 12e1770
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 10 deletions.
24 changes: 24 additions & 0 deletions src/components/SampleCategory.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@keyframes openTriangle {
from { transform: rotate(0deg); }
to { transform: rotate(180deg); }
}

@keyframes closeTriangle {
from { transform: rotate(180deg); }
to { transform: rotate(0deg); }
}

.dropdown {
margin-left: 8px;
margin-top: 7px;
margin-bottom: 5px;
}


.dropdown[data-collapsed=false] {
animation: openTriangle 0.3s forwards ease-in-out;
}

.dropdown[data-collapsed=true] {
animation: closeTriangle 0.3s forwards ease-in-out;
}
26 changes: 26 additions & 0 deletions src/components/SampleCategory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useState } from 'react';
import styles from './SampleCategory.module.css';

interface SampleCategoryProps {
title: string;
}

export const SampleCategory = ({ title }: SampleCategoryProps) => {
const [open, setOpen] = useState<boolean>(true);
return (
<div style={{ display: 'flex' }} onClick={() => setOpen(!open)}>
<h3
style={{
marginTop: '5px',
}}
>
{title}
</h3>
<div className={`${styles.dropdown}`} data-collapsed={open}>
<svg width="15" height="15" viewBox="0 0 20 20">
<path d="M0 7 L 20 7 L 10 16" fill="black" />
</svg>
</div>
</div>
);
};
6 changes: 6 additions & 0 deletions src/pages/MainLayout.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
margin-block-end: 16px;
}

.exampleList h3 {
color: rgb(43, 126, 171);
}

.exampleList li {
list-style: none;
padding: 0.3em 0;
Expand All @@ -49,6 +53,8 @@
max-height: 100vh;
}



@media only screen and (max-width: 768px) {
/* More padding on mobile for easier touch screen use */
.exampleLink {
Expand Down
12 changes: 2 additions & 10 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import styles from './MainLayout.module.css';

import { pageCategories } from './samples/[slug]';
import { SampleLink } from '../components/SampleLink';
import { SampleCategory } from '../components/SampleCategory';

const title = 'WebGPU Samples';

Expand All @@ -17,7 +18,6 @@ const MainLayout: React.FunctionComponent<AppProps> = ({
pageProps,
}) => {
const router = useRouter();
//const samplesNames = Object.keys(pages);
const [listExpanded, setListExpanded] = useState<boolean>(false);

const ComponentMemo = useMemo(() => {
Expand Down Expand Up @@ -69,15 +69,7 @@ const MainLayout: React.FunctionComponent<AppProps> = ({
className={styles.exampleList}
key={`/categories/${category.title}`}
>
<h3
style={{
marginTop: '5px',
marginBottom: '5px',
color: 'rgb(43, 126, 171)',
}}
>
{category.title}
</h3>
<SampleCategory title={category.title} />
{category.sampleNames.map((slug) => {
return (
<SampleLink
Expand Down
5 changes: 5 additions & 0 deletions src/pages/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ a:hover {
text-decoration: underline;
}

h3 {
margin-bottom: 5px;
margin-top: 5px;
}

main {
position: relative;
flex: 1;
Expand Down

0 comments on commit 12e1770

Please sign in to comment.