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

Add descriptions to categories on hover #360

Merged
merged 30 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 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
1db2e10
Merge branch 'webgpu:main' into main
cmhhelgeson Feb 21, 2024
ebbb389
Encapsulated sample page link logic into its own component, which wil…
cmhhelgeson Feb 28, 2024
73f26d7
Test
cmhhelgeson Feb 28, 2024
5419898
New sidebar layout
cmhhelgeson Feb 28, 2024
970f069
First draft
cmhhelgeson Feb 28, 2024
12e1770
Sketch dropdown before merging main into this branch
cmhhelgeson Feb 28, 2024
8bfa289
Merge branch 'webgpu:main' into main
cmhhelgeson Feb 28, 2024
1879c54
merge main into sample_organize_branch
cmhhelgeson Feb 28, 2024
f3c618c
Dropdowns complete. Note that dropdowns can easily be removed if they…
cmhhelgeson Feb 28, 2024
bc57254
fix build errors
cmhhelgeson Feb 28, 2024
8a980a8
Implemented most suggested changes, will have further discussions abo…
cmhhelgeson Feb 28, 2024
95334d3
Moved stuffed around, added comments justifying each category
cmhhelgeson Feb 29, 2024
f05a846
Capitalize GPGPU
cmhhelgeson Feb 29, 2024
40ee507
Added more specific comments to gpgpu section
cmhhelgeson Feb 29, 2024
14c55f8
Cambios pequenos
cmhhelgeson Feb 29, 2024
4f03134
Add descriptions to categories
cmhhelgeson Feb 29, 2024
e264cb3
Merge branch 'main' into sample_organize_branch
cmhhelgeson Feb 29, 2024
be6a20f
Merge branch 'webgpu:main' into main
cmhhelgeson Feb 29, 2024
ee7f89f
Merge branch 'main' into sample_organize_branch
cmhhelgeson Feb 29, 2024
f09bb8e
Fixed build errors
cmhhelgeson Feb 29, 2024
c56edee
fixed error
cmhhelgeson Feb 29, 2024
c7aad95
Fix
cmhhelgeson Feb 29, 2024
b8f35fc
Fixes
cmhhelgeson Mar 4, 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
22 changes: 21 additions & 1 deletion src/components/SampleCategory.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
.sampleCategory {
display: flex;
margin-top: 5px;
margin-bottom: 5px;
display: inline-block;
}

.sampleCategoryDescription {
position: absolute;
background-color: rgba(255, 255, 255, 0.9);
box-shadow: 0 0 5px 10px rgba(255, 255, 255, 0.9);
border-radius: 10px;
transition: opacity 0.3s ease-in, transform 0.2s ease-out
}

.sampleCategoryDescription[data-active='true'] {
opacity: 1;
transform: translateY(-0.5em);
}

.sampleCategoryDescription[data-active='false'] {
opacity: 0;
pointer-events: none;
transform: translateY(0.25em);
}

li.selected a {
color: #ff0000;
Expand Down
22 changes: 20 additions & 2 deletions src/components/SampleCategory.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styles from './SampleCategory.module.css';
import { useState } from 'react';

import { NextRouter } from 'next/router';
import Link from 'next/link';
Expand All @@ -23,17 +24,34 @@ export const SampleCategory = ({
onClickPageLink,
router,
}: SampleCategoryProps) => {
const [displayDescription, setDisplayDescription] = useState<boolean>(false);
const { title, pages, sampleNames } = category;
return (
<div>
<div className={styles.sampleCategory}>
<div
className={styles.sampleCategory}
onMouseEnter={() => {
setDisplayDescription(true);
}}
onMouseLeave={() => {
setDisplayDescription(false);
}}
>
<h3
style={{
marginTop: '5px',
cursor: 'pointer',
width: 'auto',
}}
>
{title}
</h3>

<p
className={styles.sampleCategoryDescription}
data-active={displayDescription}
>
{category.description}
</p>
</div>
{sampleNames.map((slug) => {
return (
Expand Down
4 changes: 4 additions & 0 deletions src/pages/MainLayout.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
max-height: 0px;
}

.panel[data-expanded='false'] {
overflow: hidden;
}

.panel[data-expanded='false'] .panelContents {
max-height: 0vh;
overflow: hidden;
Expand Down
47 changes: 37 additions & 10 deletions src/pages/samples/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const graphicsBasicsPages: PageComponentType = {
rotatingCube: dynamic(() => import('../../sample/rotatingCube/main')),
twoCubes: dynamic(() => import('../../sample/twoCubes/main')),
texturedCube: dynamic(() => import('../../sample/texturedCube/main')),
samplerParameters: dynamic(
() => import('../../sample/samplerParameters/main')
),
instancedCube: dynamic(() => import('../../sample/instancedCube/main')),
fractalCube: dynamic(() => import('../../sample/fractalCube/main')),
cubemap: dynamic(() => import('../../sample/cubemap/main')),
Expand All @@ -33,9 +36,6 @@ const graphicsBasicsPages: PageComponentType = {
// the primary purpose of 'sampleParameters' is to demonstrate their specific nomenclature and
// functionality within the context of the WebGPU API.
const webGPUFeaturesPages: PageComponentType = {
samplerParameters: dynamic(
() => import('../../sample/samplerParameters/main')
),
reversedZ: dynamic(() => import('../../sample/reversedZ/main')),
renderBundles: dynamic(() => import('../../sample/renderBundles/main')),
};
Expand Down Expand Up @@ -94,28 +94,55 @@ const pages: PageComponentType = {

export interface PageCategory {
title: string;
description?: string;
pages: PageComponentType;
sampleNames: string[];
}

const createPageCategory = (
title: string,
pages: PageComponentType
pages: PageComponentType,
description?: string
): PageCategory => {
return {
title,
description,
pages,
sampleNames: Object.keys(pages),
};
};

export const pageCategories: PageCategory[] = [
createPageCategory('Basic Graphics', graphicsBasicsPages),
createPageCategory('WebGPU Features', webGPUFeaturesPages),
createPageCategory('GPGPU Demos', gpuComputeDemoPages),
createPageCategory('Graphics Techniques', graphicsDemoPages),
createPageCategory('Web Platform Integration', webPlatformPages),
createPageCategory('Benchmarks', benchmarkPages),
createPageCategory(
'Basic Graphics',
graphicsBasicsPages,
'Basic rendering functionality implemented with the WebGPU API.'
),
createPageCategory(
'WebGPU Features',
webGPUFeaturesPages,
'Highlights of important WebGPU features.'
),
createPageCategory(
'GPGPU Demos',
gpuComputeDemoPages,
'Visualizations of parallel GPU compute operations.'
),
createPageCategory(
'Graphics Techniques',
graphicsDemoPages,
'A collection of graphics techniques implemented with WebGPU.'
),
createPageCategory(
'Web Platform Integration',
webPlatformPages,
'Demos integrating WebGPU with other functionalities of the web platform.'
),
createPageCategory(
'Benchmarks',
benchmarkPages,
'WebGPU Performance Benchmarks'
),
];

function Page({ slug }: Props): JSX.Element {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ a:hover {
}

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

main {
Expand Down
5 changes: 1 addition & 4 deletions src/sample/skinnedMesh/glbUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,8 @@ export class GLTFNode {

export class GLTFScene {
nodes?: number[];
name?: any;
extensions?: any;
extras?: any;
[k: string]: any;
root: GLTFNode;
name?: string;

constructor(
device: GPUDevice,
Expand Down
12 changes: 6 additions & 6 deletions src/sample/skinnedMesh/gltf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export interface Camera {
orthographic?: CameraOrthographic;
perspective?: CameraPerspective;
type: 'perspective' | 'orthographic' | string;
name?: any;
name?: string;
}

export interface Image {
Expand All @@ -123,13 +123,13 @@ export interface MaterialPbrMetallicRoughness {
metallicRoughnessTexture?: TextureInfo;
}
export interface MaterialNormalTextureInfo {
index?: any;
texCoord?: any;
index?: number;
texCoord?: number;
scale?: number;
}
export interface MaterialOcclusionTextureInfo {
index?: any;
texCoord?: any;
index?: number;
texCoord?: number;
strength?: number;
}

Expand Down Expand Up @@ -187,7 +187,7 @@ export interface Sampler {

export interface Scene {
nodes?: GlTfId[];
name?: any;
name?: string;
root?: GLTFNode;
}
export interface Skin {
Expand Down
Loading