From 844a9457f52ea16f1431274199fcdc0bce01a908 Mon Sep 17 00:00:00 2001 From: Adam Wood <1017872+adamwoodnz@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:17:07 +1300 Subject: [PATCH] Update filter and feeds layout --- src/frontend/calendar/index.js | 2 ++ src/frontend/feed/index.js | 39 ++++++++++++++++++++++++++ src/frontend/filter/index.js | 51 +++------------------------------- src/frontend/style.scss | 40 ++++++++++++-------------- 4 files changed, 63 insertions(+), 69 deletions(-) create mode 100644 src/frontend/feed/index.js diff --git a/src/frontend/calendar/index.js b/src/frontend/calendar/index.js index 22ab55f..bb24df1 100644 --- a/src/frontend/calendar/index.js +++ b/src/frontend/calendar/index.js @@ -13,6 +13,7 @@ import { speak } from '@wordpress/a11y'; import CalendarGrid from './grid'; import List from '../list'; import Filter from '../filter'; +import Feed from '../feed'; import { useViews } from '../store/view-context'; function Calendar() { @@ -106,6 +107,7 @@ function Calendar() { ) } { isListView() && } + ); } diff --git a/src/frontend/feed/index.js b/src/frontend/feed/index.js new file mode 100644 index 0000000..6eecb4f --- /dev/null +++ b/src/frontend/feed/index.js @@ -0,0 +1,39 @@ +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { addQueryArgs } from '@wordpress/url'; +import { Button, ButtonGroup } from '@wordpress/components'; + +/** + * Internal dependencies + */ +import { useEvents } from '../store/event-context'; + +const Feed = () => { + const { teams, team } = useEvents(); + const selected = teams.find( ( option ) => team === option.value ); + + const getCalendarUrl = () => { + const baseUrl = window.location.origin; + if ( ! selected ) { + return `${baseUrl}/meetings.ics`; + } + return `${baseUrl}/meetings-${selected.value}.ics`; + }; + + const getGoogleCalendarUrl = () => { + const calendarUrl = getCalendarUrl().replace('https://', 'webcal://'); + return addQueryArgs('https://www.google.com/calendar/render', { + cid: calendarUrl, + }); + }; + + return ( +
+ { __( 'Subscribe to this calendar:', 'wporg-meeting-calendar' ) } Google Calendar ↗ · ICS +
+ ); +}; + +export default Feed; \ No newline at end of file diff --git a/src/frontend/filter/index.js b/src/frontend/filter/index.js index f5605e2..9f53456 100644 --- a/src/frontend/filter/index.js +++ b/src/frontend/filter/index.js @@ -2,8 +2,7 @@ * WordPress dependencies */ import { __, sprintf } from '@wordpress/i18n'; -import { addQueryArgs } from '@wordpress/url'; -import { Button, ButtonGroup, SelectControl } from '@wordpress/components'; +import { Button, SelectControl } from '@wordpress/components'; import { speak } from '@wordpress/a11y'; import { useRef } from '@wordpress/element'; @@ -22,22 +21,6 @@ const Filter = () => { const dropdownId = 'wporg-meeting-calendar__filter-dropdown'; const selected = teams.find( ( option ) => team === option.value ); - const getCalendarUrl = () => { - const baseUrl = window.location.origin; - if ( ! selected ) { - return `${ baseUrl }/meetings.ics`; - } - - return `${ baseUrl }/meetings-${ selected.value }.ics`; - }; - - const getGoogleCalendarUrl = () => { - const calendarUrl = getCalendarUrl().replace( 'https://', 'webcal://' ); - return addQueryArgs( 'https://www.google.com/calendar/render', { - cid: calendarUrl, - } ); - }; - return (
); }; diff --git a/src/frontend/style.scss b/src/frontend/style.scss index 9fed7aa..9a9a189 100644 --- a/src/frontend/style.scss +++ b/src/frontend/style.scss @@ -325,8 +325,7 @@ } .wporg-meeting-calendar__header, -.wporg-meeting-calendar__list, -.wporg-meeting-calendar__filter { +.wporg-meeting-calendar__list { padding: 12px; } @@ -443,30 +442,25 @@ .wporg-meeting-calendar__filter { display: flex; + flex-wrap: wrap; align-items: center; - border: 1px solid #ddd; - background: #eee; + margin: var(--wp--preset--spacing--20, 20px) 0; + + .components-base-control__field { + margin-bottom: unset; + } } .wporg-meeting-calendar__filter-dropdown { max-width: none; } -.wporg-meeting-calendar__filter-feed { - margin-left: auto; - margin-top: 0; -} - -.wporg-meeting-calendar__filter-feed .components-button { - padding-right: 12px; -} - -.wporg-meeting-calendar__filter-feed .components-button.has-icon .dashicon { - margin-right: 6px; -} +.wporg-meeting-calendar__filter-remove.components-button.is-link { + text-decoration: none; -.wporg-meeting-calendar__filter-feed .components-button:first-of-type { - margin-right: -1px; + span:not(.dashicons) { + text-decoration: underline; + } } @media ( max-width: 782px ) { @@ -481,10 +475,6 @@ .wporg-meeting-calendar__filter-dropdown { max-width: 200px; } - - .wporg-meeting-calendar__filter-feed { - margin-top: 8px; - } } .wporg-meeting-calendar__filter-label { @@ -531,3 +521,9 @@ .meeting-cancelled .wporg-meeting-detail { text-decoration: line-through; } + +.wporg-meeting-calendar__feed { + margin-top: 8px; + text-align: right; + font-size: var(--wp--preset--font-size--small, 14px); +}