From 2829904771461c9b69b4227ce4b14a15f43f9135 Mon Sep 17 00:00:00 2001 From: Toby Brancher Date: Tue, 17 Jul 2018 14:50:44 +0100 Subject: [PATCH] Tweaks/counter bar (#23) * Styling tweaks related to CounterBar * Update snapshot * Add flex-start to outer wrapper * Add story without counters wrapper --- .../src/__snapshots__/test.js.snap | 31 +++++++++---------- components/counter-bar/src/index.js | 29 +++++++---------- components/counter-bar/src/stories.js | 11 +++++++ components/result-count-title/src/index.js | 12 +++---- components/title-result-count/src/index.js | 4 ++- packages/storybook/package.json | 1 + 6 files changed, 48 insertions(+), 40 deletions(-) diff --git a/components/counter-bar/src/__snapshots__/test.js.snap b/components/counter-bar/src/__snapshots__/test.js.snap index 49620b2..094a9e7 100644 --- a/components/counter-bar/src/__snapshots__/test.js.snap +++ b/components/counter-bar/src/__snapshots__/test.js.snap @@ -6,17 +6,21 @@ exports[`CounterBar matches snapshot 1`] = ` display: -webkit-flex; display: -ms-flexbox; display: flex; - -webkit-flex-wrap: nowrap; - -ms-flex-wrap: nowrap; - flex-wrap: nowrap; + -webkit-flex-wrap: wrap; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + -webkit-align-items: flex-start; + -webkit-box-align: flex-start; + -ms-flex-align: flex-start; + align-items: flex-start; line-height: 1; } .emotion-6 { border: 0px; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; margin: 0 6px 6px 0; max-width: 250px; outline: none; @@ -30,6 +34,8 @@ exports[`CounterBar matches snapshot 1`] = ` .emotion-4 { display: inline-block; + white-space: nowrap; + text-overflow: ellipsis; } .emotion-0 { @@ -73,18 +79,15 @@ exports[`CounterBar matches snapshot 1`] = ` .emotion-14 { border: 0px; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; margin: 0 6px 6px 0; max-width: 250px; outline: none; padding: 0 8px 0 0; background: #ffffff; color: #ffffff; - -webkit-flex: 1; - -ms-flex: 1; - flex: 1; background: #6f777b; } @@ -92,10 +95,6 @@ exports[`CounterBar matches snapshot 1`] = ` outline: solid 4px #ffbf47; } -.emotion-14:last-child { - margin-right: 0px; -} - ({ background: active ? LINK_COLOUR : GREY_1, @@ -181,7 +176,7 @@ const CounterWrapper = styled(TotalWrapper)( * Use a Link component for the total * ```jsx * import { HashRouter, Link } from 'react-router-dom'; - * + * * * * All counters @@ -211,7 +206,7 @@ const CounterWrapper = styled(TotalWrapper)( * Use a Link component for a counter * ```jsx * import { HashRouter, Link } from 'react-router-dom'; - * + * * * * All counters diff --git a/components/counter-bar/src/stories.js b/components/counter-bar/src/stories.js index 2c20916..f95dadb 100644 --- a/components/counter-bar/src/stories.js +++ b/components/counter-bar/src/stories.js @@ -52,6 +52,17 @@ examples.add('Active total', () => ), ); +examples.add('Without Counters wrapper', () => + ( + All counters + Counter 1 + Counter 2 + Counter 3 + Counter 4 + Counter 5 + ), +); + examples.add('Empty counters', () => ( All counters diff --git a/components/result-count-title/src/index.js b/components/result-count-title/src/index.js index 1dd5ae2..8c86d88 100644 --- a/components/result-count-title/src/index.js +++ b/components/result-count-title/src/index.js @@ -4,11 +4,11 @@ import styled from 'react-emotion'; import ResultCount from '@govuk-frederic/result-count'; -const Wrapper = styled('div')( - { - display: 'inline-block', - }, -); +const Wrapper = styled('div')({ + display: 'inline-block', + whiteSpace: 'nowrap', + textOverflow: 'ellipsis', +}); const Title = styled('div')({ display: 'inline-block', @@ -26,7 +26,7 @@ const Title = styled('div')({ * ```jsx * Title * ``` - * + * * In black with count value 0 * ```jsx * Title diff --git a/components/title-result-count/src/index.js b/components/title-result-count/src/index.js index 0a19122..adfaf53 100644 --- a/components/title-result-count/src/index.js +++ b/components/title-result-count/src/index.js @@ -6,6 +6,8 @@ import ResultCount from '@govuk-frederic/result-count'; const Wrapper = styled('div')({ display: 'inline-block', + whiteSpace: 'nowrap', + textOverflow: 'ellipsis', }); const Title = styled('div')({ @@ -26,7 +28,7 @@ const Title = styled('div')({ * Title Title Title * * ``` - * + * * Counter title with value 0 and override text and background colour. * ```jsx * diff --git a/packages/storybook/package.json b/packages/storybook/package.json index 142dd60..7204285 100644 --- a/packages/storybook/package.json +++ b/packages/storybook/package.json @@ -18,6 +18,7 @@ "@govuk-frederic/spinner": "^0.0.1", "@govuk-frederic/table": "^0.0.1", "@govuk-frederic/table-accordion-group": "^0.0.1", + "@govuk-frederic/table-of-contents": "^0.0.1", "@govuk-frederic/title-result-count": "^0.0.1", "@storybook/addon-actions": "^3.4.1", "@storybook/addon-knobs": "^3.4.1",