Skip to content

The swiss army knife of lossless video/audio editing

Website: collapse the reviews and usage scenarios on phones too, with one <Collapsible> component

Claude20c4a7bffae1
diff --git a/website/src/components/Home.tsx b/website/src/components/Home.tsx
index b1e4f064..28f70497 100644
--- a/website/src/components/Home.tsx
+++ b/website/src/components/Home.tsx
@@ -1,5 +1,5 @@
// The homepage content. Rendered to static HTML at build time (no client-side JavaScript).
-import type { ReactNode } from 'react';
+import type { CSSProperties, ReactNode } from 'react';
import type { LucideIcon } from 'lucide-react';
import { AudioWaveform, Camera, Clock, CodeXml, Combine, Layers, ListOrdered, Monitor, PackageOpen, RefreshCw, RotateCw, Save, Scissors, Star, Tag, Terminal, ZoomIn } from 'lucide-react';
@@ -103,6 +103,17 @@ function List({ items }: { items: string[] }) {
);
}
+// On phones, shows only the first collapsedHeight px of children (a single element), fading out, until the "label" button is
+// clicked. CSS only (a <details> and :has(), see .collapsible in home.css): wider screens and browsers without :has() show everything.
+function Collapsible({ label, collapsedHeight, children }: { label: string, collapsedHeight: number, children: ReactNode }) {
+ return (
+ <div className="collapsible" style={{ '--collapsed-height': `${collapsedHeight}px` } as CSSProperties}>
+ {children}
+ <details className="collapsible-more"><summary className="button">{label}</summary></details>
+ </div>
+ );
+}
+
function FooterLink({ href, children }: { href: string, children: ReactNode }) {
return <><a className="footer-link" href={href}>{children}</a>{' '}</>;
}
@@ -163,9 +174,11 @@ export default function Home({ stars }: { stars: number }) {
<section className="quotes">
<h2>Thousands of happy users</h2>
- <div className="quote-grid">
- {quotes.map((quote) => <blockquote key={quote} className="quote-card">{quote}</blockquote>)}
- </div>
+ <Collapsible label="Show all reviews" collapsedHeight={480}>
+ <div className="quote-grid">
+ {quotes.map((quote) => <blockquote key={quote} className="quote-card">{quote}</blockquote>)}
+ </div>
+ </Collapsible>
</section>
<WhiteSection>
@@ -204,8 +217,7 @@ export default function Home({ stars }: { stars: number }) {
<WhiteSection>
<h2 style={{ margin: '20px 0' }}>Features</h2>
- {/* on phones, collapsed until "Show all features" is clicked (CSS only, see home.css) */}
- <div className="feature-collapse">
+ <Collapsible label="Show all features" collapsedHeight={460}>
<div className="feature-grid">
{features.map(({ text, Icon }) => (
<div key={text} className="feature-card">
@@ -214,13 +226,14 @@ export default function Home({ stars }: { stars: number }) {
</div>
))}
</div>
- <details className="feature-more"><summary className="button">Show all features</summary></details>
- </div>
+ </Collapsible>
<h2 style={{ margin: '20px 0' }}>Other usage scenarios</h2>
<div className="list">
- <List items={usageScenarios} />
+ <Collapsible label="Show all usage scenarios" collapsedHeight={300}>
+ <List items={usageScenarios} />
+ </Collapsible>
<div style={{ marginLeft: '40px' }}>
* Which function is available depends on the file in question and which format/codec this file has<br />
diff --git a/website/src/styles/home.css b/website/src/styles/home.css
index a6ce0307..623826e4 100644
--- a/website/src/styles/home.css
+++ b/website/src/styles/home.css
@@ -242,36 +242,33 @@ body {
.feature-icon {
color: #1d8a96;
}
-.feature-collapse {
- width: 1000px;
- max-width: 100%;
- margin-bottom: 40px;
-}
-.feature-collapse .feature-grid {
- margin-bottom: 0;
+/* <Collapsible> in Home.tsx: on phones, the first --collapsed-height of its content element, fading out, until the <details> is
+opened. Only where :has() works, so other browsers show everything. The wrapper takes no space of its own (display: contents),
+so the content element keeps its layout. */
+.collapsible {
+ display: contents;
}
-.feature-more {
+.collapsible-more {
display: none;
}
-/* Phones: show the first few features, fading out, until "Show all features" opens the <details>.
-Only where :has() works, so other browsers show all features. */
@supports selector(:has(*)) {
@media (max-width: 700px) {
- .feature-collapse:not(:has(.feature-more[open])) .feature-grid {
- max-height: 460px;
+ .collapsible:not(:has(> .collapsible-more[open])) > :first-child {
+ max-height: var(--collapsed-height);
overflow: hidden;
- mask-image: linear-gradient(to bottom, black 55%, transparent);
+ mask-image: linear-gradient(to bottom, black calc(100% - 120px), transparent);
+ margin-bottom: 0;
}
- .feature-more:not([open]) {
+ .collapsible-more:not([open]) {
display: flex;
justify-content: center;
- margin-top: 8px;
+ margin: 8px 0 30px;
}
- .feature-more summary {
+ .collapsible-more summary {
list-style: none;
cursor: pointer;
}
- .feature-more summary::-webkit-details-marker {
+ .collapsible-more summary::-webkit-details-marker {
display: none;
}
}