Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS: Animated Resizing of .panelContents when Window Size is less than 768 pixels. #344

Merged
merged 20 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d51dc45
Merge pull request #1 from webgpu/main
cmhhelgeson Oct 18, 2023
766427d
Merge pull request #2 from webgpu/main
cmhhelgeson Oct 27, 2023
415bd67
Merge pull request #3 from webgpu/main
cmhhelgeson Oct 31, 2023
ff38128
Merge pull request #4 from webgpu/main
cmhhelgeson Nov 15, 2023
c4f73a1
Merge branch 'main' of https://github.com/cmhhelgeson/webgpu-samples
cmhhelgeson Nov 30, 2023
c5a9982
Merge pull request #5 from webgpu/main
cmhhelgeson Dec 4, 2023
08d811d
Merge branch 'main' of https://github.com/cmhhelgeson/webgpu-samples
cmhhelgeson Dec 4, 2023
c12ed69
Updated css for expanding list of samples when window size is less th…
cmhhelgeson Jan 4, 2024
3e2c074
fixed issue with panelContents disappearing on link click
cmhhelgeson Jan 4, 2024
0effe6d
Added helpful comments
cmhhelgeson Jan 4, 2024
e559c09
Changed function names from stylePanel to stylePanelContents to bette…
cmhhelgeson Jan 4, 2024
126890e
Fixed bug where max-height was visibly changing on resize to greater …
cmhhelgeson Jan 4, 2024
ace264b
Removed most code for simpler solution
cmhhelgeson Jan 4, 2024
33a49b5
Made sure display: block was explicit at normal window width
cmhhelgeson Jan 4, 2024
212401f
got rid of useEffect import
cmhhelgeson Jan 4, 2024
efedad9
Removed unecessary function. I definitely overcomplicated the origina…
cmhhelgeson Jan 4, 2024
1f8b4e4
Added back effect so data-expanded would be set to false on window re…
cmhhelgeson Jan 4, 2024
08d2c9f
added semicolon
cmhhelgeson Jan 4, 2024
6b1d68e
Memoized component
cmhhelgeson Jan 19, 2024
5e8f0a0
Removed unusued functions
cmhhelgeson Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/pages/MainLayout.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
}

.exampleList {
padding: 0
padding: 0;
margin-block-start: 16px;
margin-block-end: 16px;
}

.exampleList li {
Expand All @@ -40,6 +42,13 @@
background-size: cover;
}

.panel .panelContents {
display: block;
transition: max-height 0s;
overflow: none;
max-height: 100vh;
}

@media only screen and (max-width: 768px) {
/* More padding on mobile for easier touch screen use */
.exampleLink {
Expand All @@ -55,12 +64,19 @@
height: auto;
}

.panel[data-expanded=false] .panelContents {
display: none;
.panel .panelContents {
display: block;
transition: max-height 0.3s ease-out;
overflow: hidden;
max-height: 0px;
}

.panel[data-expanded='false'] .panelContents {
max-height: 0vh;
}

.panel[data-expanded=true] .panelContents {
display: block;
.panel[data-expanded='true'] .panelContents {
max-height: 100vh;
}

.expand {
Expand Down
9 changes: 6 additions & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Head from 'next/head';
import { AppProps } from 'next/app';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { useState } from 'react';
import { useMemo, memo, useState } from 'react';

import './styles.css';
import styles from './MainLayout.module.css';
Expand All @@ -21,9 +21,12 @@ const MainLayout: React.FunctionComponent<AppProps> = ({
}) => {
const router = useRouter();
const samplesNames = Object.keys(pages);

const [listExpanded, setListExpanded] = useState<boolean>(false);

const ComponentMemo = useMemo(() => {
return memo(Component);
}, [Component]);

const oldPathSyntaxMatch = router.asPath.match(/(\?wgsl=[01])#(\S+)/);
if (oldPathSyntaxMatch) {
const slug = oldPathSyntaxMatch[2];
Expand Down Expand Up @@ -107,7 +110,7 @@ const MainLayout: React.FunctionComponent<AppProps> = ({
</ul>
</div>
</nav>
<Component {...pageProps} />
<ComponentMemo {...pageProps} />
</div>
</>
);
Expand Down
Loading