diff --git a/frontend/src/metadata/components/data-process-setter/gallery-group-by-setter/index.css b/frontend/src/metadata/components/data-process-setter/gallery-group-by-setter/index.css new file mode 100644 index 0000000000..c6a8832032 --- /dev/null +++ b/frontend/src/metadata/components/data-process-setter/gallery-group-by-setter/index.css @@ -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; +} diff --git a/frontend/src/metadata/components/data-process-setter/gallery-group-by-setter/index.js b/frontend/src/metadata/components/data-process-setter/gallery-group-by-setter/index.js new file mode 100644 index 0000000000..a79364d7f4 --- /dev/null +++ b/frontend/src/metadata/components/data-process-setter/gallery-group-by-setter/index.js @@ -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 ( +