-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/year month day mode in gallery (#6725)
* add date mode in gallery * replace localStorage with sfMetadataContext.localStorage, update date tag render * update string to support translation, fix images shift up when date tag was hidden * update gallery ui * fix conflicts, update gallery-group-by-setter * fix conflict
- Loading branch information
1 parent
ce39cbd
commit 25f12a2
Showing
12 changed files
with
205 additions
and
34 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
frontend/src/metadata/components/data-process-setter/gallery-group-by-setter/index.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
.metadata-gallery-group-by-setter { | ||
width: 272px; | ||
height: 36px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
border: 1px solid #e2e2e2; | ||
border-radius: 3px; | ||
} | ||
|
||
.metadata-gallery-group-by-setter .metadata-gallery-group-by-button { | ||
width: 66px; | ||
height: 28px; | ||
background-color: #fff; | ||
position: relative; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 0.875rem; | ||
border: 0; | ||
border-radius: 2px; | ||
} | ||
|
||
.metadata-gallery-group-by-setter .metadata-gallery-group-by-button:hover { | ||
background-color: #f0f0f0; | ||
cursor: pointer; | ||
} | ||
|
||
.metadata-gallery-group-by-setter .metadata-gallery-group-by-button.active { | ||
background-color: #f5f5f5; | ||
} | ||
|
||
.metadata-gallery-group-by-setter .metadata-gallery-group-by-button span { | ||
display: block; | ||
text-align: center; | ||
width: 100%; | ||
} | ||
|
||
.metadata-gallery-group-by-button:not(:first-child)::before { | ||
content: ''; | ||
width: 1px; | ||
height: 22px; | ||
background-color: #e2e2e2; | ||
position: absolute; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
transition: opacity 0.3s; | ||
left: -1px; | ||
} | ||
|
||
.metadata-gallery-group-by-button:hover::before, | ||
.metadata-gallery-group-by-button.active::before, | ||
.metadata-gallery-group-by-button:hover + .metadata-gallery-group-by-button::before, | ||
.metadata-gallery-group-by-button.active + .metadata-gallery-group-by-button::before { | ||
opacity: 0; | ||
} |
51 changes: 51 additions & 0 deletions
51
frontend/src/metadata/components/data-process-setter/gallery-group-by-setter/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React, { useState, useCallback, useEffect } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classnames from 'classnames'; | ||
import { EVENT_BUS_TYPE, GALLERY_DATE_MODE } from '../../../constants'; | ||
import { gettext } from '../../../../utils/constants'; | ||
|
||
import './index.css'; | ||
|
||
const DATE_MODE_MAP = { | ||
[GALLERY_DATE_MODE.YEAR]: gettext('Year'), | ||
[GALLERY_DATE_MODE.MONTH]: gettext('Month'), | ||
[GALLERY_DATE_MODE.DAY]: gettext('Day'), | ||
[GALLERY_DATE_MODE.ALL]: gettext('All') | ||
}; | ||
|
||
const GalleryGroupBySetter = ({ view }) => { | ||
const [currentMode, setCurrentMode] = useState(GALLERY_DATE_MODE.DAY); | ||
|
||
useEffect(() => { | ||
const savedValue = window.sfMetadataContext.localStorage.getItem('gallery-group-by', GALLERY_DATE_MODE.DAY); | ||
setCurrentMode(savedValue || GALLERY_DATE_MODE.DAY); | ||
}, [view?._id]); | ||
|
||
const handleGroupByChange = useCallback((newMode) => { | ||
setCurrentMode(newMode); | ||
window.sfMetadataContext.localStorage.setItem('gallery-group-by', newMode); | ||
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.SWITCH_GALLERY_GROUP_BY, newMode); | ||
}, []); | ||
|
||
return ( | ||
<div className="metadata-gallery-group-by-setter"> | ||
{Object.entries(DATE_MODE_MAP).map(([dateMode, label]) => ( | ||
<button | ||
key={dateMode} | ||
className={classnames('metadata-gallery-group-by-button', { active: currentMode === dateMode })} | ||
onClick={() => handleGroupByChange(dateMode)} | ||
> | ||
<span>{label}</span> | ||
</button> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
GalleryGroupBySetter.propTypes = { | ||
view: PropTypes.shape({ | ||
_id: PropTypes.string | ||
}) | ||
}; | ||
|
||
export default GalleryGroupBySetter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
frontend/src/metadata/components/data-process-setter/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.