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

Examples: Added external tag #24281

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
25 changes: 9 additions & 16 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ <h1><a href="https://threejs.org">three.js</a></h1>

for ( const key in files ) {

const section = files[ key ];
const category = files[ key ];

const header = document.createElement( 'h2' );
header.textContent = key;
header.setAttribute( 'data-category', key );
container.appendChild( header );

for ( let i = 0; i < section.length; i ++ ) {
for ( let i = 0; i < category.length; i ++ ) {

const file = section[ i ];
const file = category[ i ];

const link = createLink( file );
const link = createLink( file, tags[ file ] );
container.appendChild( link );

links[ file ] = link;
Expand Down Expand Up @@ -201,15 +201,17 @@ <h1><a href="https://threejs.org">three.js</a></h1>

}

function createLink( file ) {
function createLink( file, tags ) {

const external = Array.isArray( tags ) && tags.includes( 'external' ) ? ' <span class="tag">external</span>' : '';

const template = `
<div class="card">
<a href="${file}.html" target="viewer">
<a href="${ file }.html" target="viewer">
<div class="cover">
<img src="screenshots/${ file }.jpg" loading="lazy" width="400" />
</div>
<div class="title">${getName( file )}</div>
<div class="title">${ getName( file ) }${ external }</div>
</a>
</div>
`;
Expand Down Expand Up @@ -319,18 +321,9 @@ <h1><a href="https://threejs.org">three.js</a></h1>

link.classList.remove( 'hidden' );

for ( let i = 0; i < res.length; i ++ ) {

text = name.replace( res[ i ], '<b>' + res[ i ] + '</b>' );

}

link.querySelector( '.title' ).innerHTML = text;

} else {

link.classList.add( 'hidden' );
link.querySelector( '.title' ).innerHTML = name;

}

Expand Down
3 changes: 2 additions & 1 deletion examples/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"webgl_loader_ttf": [ "text", "font" ],
"webgl_loader_pdb": [ "molecules", "css2d" ],
"webgl_loader_ldraw": [ "lego" ],
"webgl_loader_ifc": [ "external" ],
"webgl_lod": [ "level", "details" ],
"webgl_materials_blending": [ "alpha" ],
"webgl_materials_blending_custom": [ "alpha" ],
Expand Down Expand Up @@ -88,7 +89,7 @@
"webgl_postprocessing_unreal_bloom_selective": [ "glow" ],
"webgl_postprocessing_3dlut": [ "color grading" ],
"webgl_materials_modified": [ "onBeforeCompile" ],
"webgl_raycaster_bvh": [ "three-mesh-bvh", "query", "bounds", "tree", "accelerate", "performance", "community", "extension", "plugin", "library" ],
"webgl_raycaster_bvh": [ "external", "query", "bounds", "tree", "accelerate", "performance", "community", "extension", "plugin", "library", "three-mesh-bvh" ],
"webgl_shadowmap_csm": [ "cascade" ],
"webgl_shadowmap_pcss": [ "soft" ],
"webgl_simple_gi": [ "global illumination" ],
Expand Down
11 changes: 11 additions & 0 deletions files/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,17 @@ iframe#viewer {
line-height: calc(var(--line-height) - 6px);
}

.card .tag {
background-color: var(--background-color);
color: var(--color-blue);
margin-left: 6px;
padding: 1px 6px 2px;
borcer: 1px solid var(--color-blue)
mrdoob marked this conversation as resolved.
Show resolved Hide resolved
border-radius: 2px;
font-size: calc(var(--font-size) - 2px);
line-height: calc(var(--line-height) - 6px);
}

/* mobile */

@media all and ( max-width: 640px ) {
Expand Down