From ddf47571fdb98e6c96d6f9b2533d09a8a07e4d37 Mon Sep 17 00:00:00 2001 From: acdunham Date: Fri, 30 Jun 2023 10:27:28 +1200 Subject: [PATCH] Update styles to match new design --- packages/tupaia-web/src/theme/GlobalStyle.tsx | 6 + .../DateRangePicker/DatePickerDialog.tsx | 141 ++++++++++++------ 2 files changed, 98 insertions(+), 49 deletions(-) diff --git a/packages/tupaia-web/src/theme/GlobalStyle.tsx b/packages/tupaia-web/src/theme/GlobalStyle.tsx index f70d1a6e43..8205e607e2 100644 --- a/packages/tupaia-web/src/theme/GlobalStyle.tsx +++ b/packages/tupaia-web/src/theme/GlobalStyle.tsx @@ -13,6 +13,9 @@ export const GlobalStyle = createGlobalStyle<{ theme: Theme; }>` #date-picker-dialog { + h3 { + font-weight: ${({ theme }) => theme.typography.fontWeightRegular}; + } .MuiSelect-root { color: ${({ theme }) => theme.palette.text.primary}; &:focus { @@ -22,5 +25,8 @@ export const GlobalStyle = createGlobalStyle<{ .MuiInputBase-root { background-color: transparent; } + button { + text-transform: none; + } } `; diff --git a/packages/ui-components/src/components/DateRangePicker/DatePickerDialog.tsx b/packages/ui-components/src/components/DateRangePicker/DatePickerDialog.tsx index eb09449862..e1f3e9d75b 100644 --- a/packages/ui-components/src/components/DateRangePicker/DatePickerDialog.tsx +++ b/packages/ui-components/src/components/DateRangePicker/DatePickerDialog.tsx @@ -7,6 +7,7 @@ import React, { useState } from 'react'; import moment from 'moment'; import styled from 'styled-components'; +import { Typography } from '@material-ui/core'; import { DEFAULT_MIN_DATE, GRANULARITIES, @@ -35,18 +36,34 @@ const { SINGLE_YEAR, } = GRANULARITIES; -const Container = styled.div` +const Container = styled.fieldset` display: flex; margin-top: 1rem; + padding: 0; + border: none; + margin-inline-start: 0; + margin-inline-end: 0; + padding-block-start: 0; + padding-inline-start: 0; + padding-inline-end: 0; + padding-block-end: 0; + justify-content: space-between; .MuiFormControl-root { - margin-right: 1rem; + margin-right: 0.4rem; + flex: 1; &:last-child { margin-right: 0; } } + .MuiFormLabel-root { + font-size: 0.875rem; + font-weight: ${({ theme }) => theme.typography.fontWeightMedium}; + margin-bottom: 0.4rem; + } .MuiSelect-root { color: ${props => props.theme.palette.text.primary}; + font-size: 0.875rem; &:focus { background-color: transparent; } @@ -56,64 +73,88 @@ const Container = styled.div` } `; +const RowLegendWrapper = styled.div` + display: flex; + align-items: center; + margin-right: 0.5rem; + width: 15%; +`; +const RowLegend = styled(Typography).attrs({ + component: 'legend', +})` + padding-inline-end: 0; + padding-inline-start: 0; + font-size: 0.875rem; +`; + type DateRowProps = (BaseDatePickerProps | YearPickerProps | WeekPickerProps) & { granularity: typeof GRANULARITY_SHAPE; + title?: string; }; -const DateRow = ({ granularity, ...props }: DateRowProps) => { - switch (granularity) { - default: - case DAY: - return ( - - - - - - ); - case SINGLE_WEEK: - case WEEK: - return ( - - - - - ); - case MONTH: - case SINGLE_MONTH: - return ( - - - - - ); - case QUARTER: - case SINGLE_QUARTER: - return ( - - - - - ); - case YEAR: - case SINGLE_YEAR: - return ( - - - - ); - } + +const DateRow = ({ title, granularity, ...props }: DateRowProps) => { + const getDatePickerComponent = () => { + switch (granularity) { + default: + case DAY: + return ( + <> + + + + + ); + case SINGLE_WEEK: + case WEEK: + return ( + <> + + + + ); + case MONTH: + case SINGLE_MONTH: + return ( + <> + + + + ); + case QUARTER: + case SINGLE_QUARTER: + return ( + <> + + + + ); + case YEAR: + case SINGLE_YEAR: + return ; + } + }; + return ( + + {title && ( + + {title} + + )} + {getDatePickerComponent()} + + ); }; const getLabelText = (granularity: string) => { switch (granularity) { default: - return 'Select Dates'; + return 'Select dates'; case SINGLE_WEEK: - return 'Select Week'; + return 'Select week'; case SINGLE_MONTH: - return 'Select Month'; + return 'Select month'; case SINGLE_YEAR: - return 'Select Year'; + return 'Select year'; } }; @@ -204,6 +245,7 @@ export const DatePickerDialog = ({ maxMomentDate={maxMomentDate} onChange={setSelectedStartDate} weekDisplayFormat={weekDisplayFormat} + title="Start date" /> )} {errorMessage ? {errorMessage} : null}