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 handling for details & summary tags (collapsible sections) #1567

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2d874af
Working summary-details, todo cleanup, newline support & generallayou…
kravhen Oct 27, 2024
dcb4e06
pre-unist-visit review and tweaks
kravhen Nov 1, 2024
b3547d1
details & summary tags w functional inner markdown
kravhen Nov 10, 2024
004c947
Clean up comments and improve readability
kravhen Nov 10, 2024
db2734c
Merge branch 'stackernews:master' into collapsible-section
kravhen Nov 10, 2024
71db2f9
Lint fixes
kravhen Nov 10, 2024
d5c928f
Merge branch 'collapsible-section' of github.com:kravhen/stacker.news…
kravhen Nov 10, 2024
8d06842
Handle blank lines, prevent some nodes breaking details tag
kravhen Nov 17, 2024
8ff9373
Revert "Handle blank lines, prevent some nodes breaking details tag"
kravhen Nov 17, 2024
9c75beb
cleanup
kravhen Nov 17, 2024
5156da6
support details/summary tags, allow markdown inside
kravhen Nov 17, 2024
a5a90b8
fix: linting
kravhen Nov 17, 2024
1015cb2
Working structure 2, with or without blank lines
kravhen Nov 18, 2024
b8b02ce
Makeover checkpoint: close to working with newlines breaking tags or …
kravhen Nov 24, 2024
cde3f12
Handle blanklines (extra newlines) that break formatting
kravhen Dec 2, 2024
684e5ae
Refactoring and reorganize, cleanup
kravhen Dec 2, 2024
8cb5874
Add minimal styling to details and summary components
kravhen Dec 2, 2024
087f1fe
Sync pull merge cleanup
kravhen Dec 2, 2024
7bbadb9
Remove old file as reference
kravhen Dec 2, 2024
77428a9
Linting & remove isOpen state from Details component (already handled)
kravhen Dec 2, 2024
0cff503
Merge branch 'master' into collapsible-section
kravhen Dec 2, 2024
f19fce2
Structure 1 & 1A perfect beheavior
kravhen Dec 16, 2024
7415f7d
Structures 1, 1A, 2, 2A perfect behavior
kravhen Dec 16, 2024
0ee8584
Working implementation w/ useful logs to test
kravhen Dec 18, 2024
c96a4d2
Cleanup and reorg new code to bottom
kravhen Dec 18, 2024
41e362e
linting
kravhen Dec 18, 2024
f166ffd
styling touchup and cleanup
kravhen Dec 20, 2024
23fe63f
Merge branch 'master' into collapsible-section
kravhen Dec 20, 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
20 changes: 19 additions & 1 deletion components/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ export default memo(function Text ({ rel = UNKNOWN_LINK_REL, imgproxyUrls, child
return <Link id={props.id} target='_blank' rel={rel} href={href}>{children}</Link>
},
img: TextMediaOrLink,
embed: Embed
embed: Embed,
details: Details,
summary: Summary
}), [outlawed, rel, TextMediaOrLink, topLevel])

const carousel = useCarousel()
Expand Down Expand Up @@ -252,3 +254,19 @@ function P ({ children, node, onlyImages, somethingBefore, somethingAfter, ...pr
</div>
)
}

function Details ({ children, node, ...props }) {
return (
<details className={styles.details} {...props}>
{children}
</details>
)
}

function Summary ({ children, node, ...props }) {
return (
<summary className={styles.summary} {...props}>
{children}
</summary>
)
}
29 changes: 28 additions & 1 deletion components/text.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,31 @@
max-width: 480px;
border-radius: 13px;
overflow: hidden;
}
}

/* Details/Summary styling */
.details {
border: 1px solid rgba(220, 220, 220, 0.5);
border-radius: 4px;
padding: 1rem;
margin: calc(var(--grid-gap) * 0.5) 0;
transition: all 0.2s ease;
}

.details[open] {
border-color: rgba(249, 217, 94, 0.5);
}

.summary {
cursor: pointer;
color: rgba(220, 220, 220, 0.5);
transition: color 0.2s ease;
}

.details[open] > .summary {
color: rgba(249, 217, 94, 0.5);
}

.summary:hover {
color: #f9d95e;
}
Loading
Loading