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

Fix sections UI for non-collapsible structures #692

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 7 additions & 4 deletions src/components/StructuredNavigation/StructuredNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,15 @@ const StructuredNavigation = ({ showAllSectionsButton = false, sectionsHeading =
return (
<div className={cx(
'ramp--structured-nav',
hasCollapsibleStructRef.current ? ' display' : ''
showAllSectionsButton && !playlist.isPlaylist ? ' display' : ''
)}>
{hasCollapsibleStructRef.current &&
{showAllSectionsButton && !playlist.isPlaylist &&
<div className='ramp--structured-nav__sections'>
<span className='ramp--structured-nav__sections-text'>{sectionsHeading}</span>
<CollapseExpandButton numberOfSections={structureItemsRef.current?.length} />
<span className={cx(
'ramp--structured-nav__sections-text',
hasRootRangeRef.current && 'hidden' // hide 'Sections' text when a root Range exists
)}>{sectionsHeading}</span>
{hasCollapsibleStructRef.current && <CollapseExpandButton numberOfSections={structureItemsRef.current?.length} />}
</div>
}
<div className="ramp--structured-nav__border">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
StructuredNavigation component, renders any available structural properties in a given IIIF manifest. This component reads data from state provided through Contexts, therefore it should be wrapped by the context providers (both Manifest and Player as seen below).

`StructuredNavigation` component has the following prop;
- `showAllSectionsButton`: accepts a Boolean value, which has a default value of `false` and is _not required_. This allows to display the collapse/expand all sections button above the structure for manifests with collapsible structures.
- `showAllSectionsButton`: accepts a Boolean value, which has a default value of `false` and is _not required_. This allows to display the collapse/expand all sections button with a text heading (given as the value for the `sectionsHeading` prop) above structures. Collapse/expand all sections button is displayed only for manifests with collapsible structures even when this prop is turned on.
- `sectionsHeading`: accepts a String value, which has a default value of `Sections` and is _not required_. This allows to customize the text that is shown next to collapse/expand all sections button at the top of collapsible structures.

To import this component from the library;
Expand Down
7 changes: 5 additions & 2 deletions src/components/StructuredNavigation/StructuredNavigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
margin-top: 1em;
display: flex;
justify-content: space-between;
padding: 0.5em 0.5em 0;
padding: 0.5em;
background-color: $primaryLightest;
border: 1px solid $primaryLight;
border-radius: 0.25em 0.25em 0 0;
Expand All @@ -16,6 +16,9 @@
.ramp--structured-nav__sections-text {
font-weight: bold;
font-size: 1.25em;
&.hidden {
visibility: hidden;
}
}

.ramp--structured-nav__collapse-all-btn {
Expand All @@ -25,7 +28,7 @@
border: none;
border-radius: 0.3em;
cursor: pointer;
margin-bottom: 0.5rem;
align-items: flex-end;

.arrow {
border: solid $primaryLightest;
Expand Down