diff --git a/projects/js-packages/components/components/threats-data-views/index.tsx b/projects/js-packages/components/components/threats-data-views/index.tsx index b859212392957..eead872a61ece 100644 --- a/projects/js-packages/components/components/threats-data-views/index.tsx +++ b/projects/js-packages/components/components/threats-data-views/index.tsx @@ -16,6 +16,7 @@ import { __ } from '@wordpress/i18n'; import { Icon } from '@wordpress/icons'; import { useCallback, useMemo, useState } from 'react'; import Badge from '../badge'; +import useBreakpointMatch from '../layout/use-breakpoint-match'; import ThreatFixerButton from '../threat-fixer-button'; import ThreatSeverityBadge from '../threat-severity-badge'; import { @@ -91,6 +92,8 @@ export default function ThreatsDataViews( { onUnignoreThreats?: ActionButton< Threat >[ 'callback' ]; header?: JSX.Element; } ): JSX.Element { + const [ isSm ] = useBreakpointMatch( [ 'sm', 'lg' ], [ null, '<' ] ); + const baseView = { sort: { field: 'severity', @@ -126,14 +129,21 @@ export default function ThreatsDataViews( { }, }; + /** + * Default View Type. + * + * Set the default view type (list or table) based on the initial screen size. + */ + const defaultViewType: 'list' | 'table' = isSm ? 'list' : 'table'; + /** * DataView view object - configures how the dataset is visible to the user. * * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-dataviews/#view-object */ const [ view, setView ] = useState< View >( { - type: 'table', - ...defaultLayouts.table, + type: defaultViewType, + ...defaultLayouts[ defaultViewType ], } ); /** diff --git a/projects/plugins/protect/src/js/routes/home/styles.module.scss b/projects/plugins/protect/src/js/routes/home/styles.module.scss index 987e865644066..c4fd97d1e5211 100644 --- a/projects/plugins/protect/src/js/routes/home/styles.module.scss +++ b/projects/plugins/protect/src/js/routes/home/styles.module.scss @@ -2,11 +2,6 @@ padding-left: 0; padding-right: 0; overflow: hidden; - - > * { - margin-left: calc( var( --spacing-base ) * -3 ); // -24px - margin-right: calc( var( --spacing-base ) * -3 ); // -24px - } } .view-scan-report { diff --git a/projects/plugins/protect/src/js/routes/scan/styles.module.scss b/projects/plugins/protect/src/js/routes/scan/styles.module.scss index 9cc81ff35427d..f76cd3c47ee7e 100644 --- a/projects/plugins/protect/src/js/routes/scan/styles.module.scss +++ b/projects/plugins/protect/src/js/routes/scan/styles.module.scss @@ -1,3 +1,15 @@ +.scan-results-container { + :global { + @media ( max-width: 599px ) { + div.dataviews-wrapper .dataviews__view-actions { + flex-wrap: wrap; + justify-content: center; + gap: calc( var( --spacing-base ) * 1.5 ); // 12px; + } + } + } +} + .hero-main { max-width: 550px; } @@ -17,11 +29,6 @@ padding-left: 0; padding-right: 0; overflow: hidden; - - > * { - margin-left: calc( var( --spacing-base ) * -3 ); // -24px - margin-right: calc( var( --spacing-base ) * -3 ); // -24px - } } .progress-animation { @@ -33,3 +40,7 @@ .last-checked { width: fit-content; } + +.toggle-group-control { + min-width: 300px; +}