Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support responsive size values for Headline #196

Merged
merged 2 commits into from
Jan 7, 2022

Conversation

nlopin
Copy link
Contributor

@nlopin nlopin commented Dec 17, 2021

What:

Change the size of the headline depending on the viewport size.

You can pass a responsive value to the size prop of the Headline component and it will change the size depending on the viewport. For example, <Headline size={{_: 's', m: 'xl'}}>headline`.

Why:

Closes #189

How:

  • Used system function from the styled-system to define the list of possible values for headline CSS properties line-height and font-size
  • Pass the size prop to the style function returned by system to get responsive styles

Media:

https://www.loom.com/share/62e01f42c7d1449e9adbf1a7eb227db6

Checklist:

  • Ready to be merged

@rafael-sepeda
Copy link

@nlopin I have a proposal: since the behavior of the headline, in this case, will depend on the viewport maybe we should call the attribute viewport, instead of size? I think size is a bit confusing because we already use it to define the actual size in the code:

    /**
     * Set the style of the headline
     */
    size?: 'xxl' | 'xl' | 'l' | 'm' | 's' | 'xs';
....
    switch (size) {
        case 'xxl':
            return h1Styles;
        case 'xl':
            return css`
                font-size: ${get('fontSizes.5')};
                line-height: 2.5rem;
            `;
        case 'l':
            return css`
                font-size: ${get('fontSizes.4')};
                line-height: 2rem;
            `;

so use something like <Headline viewport={{_: 's', m: 'xl'}}>?
And then we can use the same logic for the Text component, in the future for spacers and other things that might depend on the viewport. Or I understand something wrong?

@nlopin
Copy link
Contributor Author

nlopin commented Dec 23, 2021

I'd like us to look at the component in isolation, without thinking about the UI the headline will be placed to. When using a component in the code, we describe the properties the component has. In that perspective current API provides clarity:

  • as which tag to use
  • size how big is the headline

If we replace size with viewport it doesn't provide any intuition, because it describes something outside of the component itself.

This is the approach we follow through the whole design system (for margins, paddings, etc). A developer can set different values to a prop depending on the screen size, but it is not mandatory. This viewport thing is an optional trick they can use, but it is opt-out by default:

<Headline size='l' mb={2}>Big title</Headline> // size for all the screens with margin-bottom fixed
<Headline size={{_: 'm', medium: 'xl'}} mb={{_: 0, medium: 2}}>Big title</Headline> // size and margin depends on the screen

If we use viewport instead of size, it loses the readability, especially in the default case (and we loose margin):

<Headline viewport='l'>Big title</Headline> // size for all the screens
<Headline viewport={{_: 'm', medium: 'xl'}}>Big title</Headline> // depends on the screen

In my opinion, the size should stay, because we set size depending on the viewport, but not the other way around.

@nlopin nlopin merged commit a3f7219 into main Jan 7, 2022
@nlopin nlopin deleted the 189/headline-responsive-style branch January 7, 2022 12:01
@github-actions
Copy link
Contributor

🎉 This PR is included in version 1.17.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

martimalek added a commit that referenced this pull request Jul 11, 2022
* chore(release): 1.15.1 [skip ci]

### [1.15.1](v1.15.0...v1.15.1) (2021-10-15)

### Bug Fixes

* adding disabled state for datepicker ([#181](#181)) ([313f424](313f424))

* test: re-enabling and fixing the tests for PhoneInput (#183)

Author: @lloydaf

* feat: added Accordion component (#172)

* feat: add Accordion component and basic documentation

* feat: added test

* chore: remove default export and add PropsWithChildren

* chore: update api table

* chore: chheck place holder to not be in document

* chore: added onExpand and onCollapse

* chore: solve lint issues

* chore: solve lint issues

* chore: solve lint issues

Co-authored-by: David Barrera <d.barrera@mytaxi.com>

* chore(release): 1.16.0 [skip ci]

## [1.16.0](v1.15.1...v1.16.0) (2021-10-25)

### Features

* added Accordion component ([#172](#172)) ([439b67c](439b67c))

* fix: add layout props to TableHeaderCell and TableCell (#185)

* chore(release): 1.16.1 [skip ci]

### [1.16.1](v1.16.0...v1.16.1) (2021-10-26)

### Bug Fixes

* add layout props to TableHeaderCell and TableCell ([#185](#185)) ([0915c58](0915c58))

* fix: cleanup Modal timeout (#193)

* chore(release): 1.16.2 [skip ci]

### [1.16.2](v1.16.1...v1.16.2) (2021-11-17)

### Bug Fixes

* cleanup Modal timeout ([#193](#193)) ([fcb1341](fcb1341))

* feat: add secondary variant for text component (#170)

* chore(release): 1.17.0 [skip ci]

## [1.17.0](v1.16.2...v1.17.0) (2021-12-09)

### Features

* add secondary variant for text component ([#170](#170)) ([f056fea](f056fea))

* Replace Chris with Leo

* Support responsive `size` values for Headline (#196)

* fix: spread Box props correctly

Closes issue #190 

* test: add test that reproduces the bug

* fix: add default theme declaration

* fix: avoid collision of `color` prop

* chore: remove StyledComponentBase typing

* fix: update prop compatibility

* test: remove snapshot

* chore(release): 1.17.1 [skip ci]

### [1.17.1](v1.17.0...v1.17.1) (2022-01-26)

### Bug Fixes

* spread Box props correctly ([9dac265](9dac265)), closes [#190](#190)

* Feat/add missing icons (#200)

* feat: update assets icons to match design icons

* feat: generate icons with new asset icons

* fix: redirect import deprecated icons to icon/index

* fix: import icons from icons/index file

* docs: add new icons & divide in sections

* test: update snapshots style-components classes names

Co-authored-by: Leonardo Di Vittorio <leo@MacBook-Pro-de-Leonardo.local>

* feat: add grid system components (#198)

* test: add test that reproduces the bug

* fix: add default theme declaration

* fix: avoid collision of `color` prop

* chore: remove StyledComponentBase typing

* fix: update prop compatibility

* feat: add grid system components

* refactor: use flexbox approach

* refactor: rework flex approach

* docs: add stacking card example

* fix: remove unnused import

* test: add snapshot tests

* feat: avoid setting marging left when 0

* feat: only use 4 decimals

* test: remove old snapshot

* Feat/add missing icons (#200)

* feat: update assets icons to match design icons

* feat: generate icons with new asset icons

* fix: redirect import deprecated icons to icon/index

* fix: import icons from icons/index file

* docs: add new icons & divide in sections

* test: update snapshots style-components classes names

Co-authored-by: Leonardo Di Vittorio <leo@MacBook-Pro-de-Leonardo.local>

* 1.17.2-canary.0

* chore: expose grid components

Co-authored-by: Leonardo <leonardo.divittorio@live.it>
Co-authored-by: Leonardo Di Vittorio <leo@MacBook-Pro-de-Leonardo.local>

* chore(release): 1.18.0 [skip ci]

## [1.18.0](v1.17.1...v1.18.0) (2022-02-01)

### Features

* add grid system components ([#198](#198)) ([c435683](c435683)), closes [#200](#200)

* docs: update changelog

* fix: replace weak prop with secondary (#206)

* chore(release): 1.18.1 [skip ci]

### [1.18.1](v1.18.0...v1.18.1) (2022-02-05)

### Bug Fixes

* replace weak prop with secondary ([#206](#206)) ([37a7f4f](37a7f4f))

* feat: remove brand colors from semantic colors object (#208)

* chore(release): 1.19.0 [skip ci]

## [1.19.0](v1.18.1...v1.19.0) (2022-03-08)

### Features

* remove brand colors from semantic colors object ([#208](#208)) ([1ccb794](1ccb794))

* feat: adds select page size component (#201)

* chore(release): 1.20.0 [skip ci]

## [1.20.0](v1.19.0...v1.20.0) (2022-04-21)

### Features

* adds select page size component ([#201](#201)) ([068b958](068b958))

* Update MAINTAINERS.md

* Update CODEOWNERS

* chore: use generated id as key in datepicker (#214)

Co-authored-by: Martí Malek <marti.malek@free-now.com>

* docs: updated docs for table (#223)

* feature: Add Divider component to Wave (#221)

* feat: add Divider component to Wave

* feat(divider): add default offset to the divider

add additional tests to check the default offset

* fix(divider): allow usage of 1px in .stylelintrc

Needed to change stylelintrc config to allow usage of px unit for divider

* Update src/components/Divider/Divider.spec.tsx

Co-authored-by: martimalek <46452321+martimalek@users.noreply.github.com>

* Update src/components/Divider/Divider.spec.tsx

Co-authored-by: martimalek <46452321+martimalek@users.noreply.github.com>

* Update src/components/Divider/docs/Divider.mdx

Co-authored-by: martimalek <46452321+martimalek@users.noreply.github.com>

* Update src/components/Divider/docs/Divider.mdx

Co-authored-by: martimalek <46452321+martimalek@users.noreply.github.com>

* Update src/components/Divider/docs/Divider.mdx

Co-authored-by: martimalek <46452321+martimalek@users.noreply.github.com>

Co-authored-by: Ján Hamara <jan.hamara@free-now.com>
Co-authored-by: martimalek <46452321+martimalek@users.noreply.github.com>

* 1.21.0

* Update changelog.mdx

Had to update changelog manually, as v1.21.0 had to also be published manually (due to PR having used feature: keyword, not feat: keyword - which caused that workflow for creating release, updating changelog and publishing package did not get triggered)

* feat: update missing icons (#228)

* feat: add missin icon svg

* feat: generate missing icons

Co-authored-by: Leonardo Di Vittorio <leonardo.divittorio@Leonardos-MacBook-Pro.local>

* chore(release): 1.22.0 [skip ci]

## [1.22.0](v1.21.0...v1.22.0) (2022-05-23)

### Features

* update missing icons ([#228](#228)) ([2f840e5](2f840e5))

* docs: fix the header UI navigation in mobile view (#231)

* feat: introduce `useToggle` hook (#220)

* chore(release): 1.23.0 [skip ci]

## [1.23.0](v1.22.0...v1.23.0) (2022-05-26)

### Features

* introduce `useToggle` hook ([#220](#220)) ([83cbad8](83cbad8))

* feat: Add Popover component to wave (#230)

* feat(popover): add popover component to wave

* feat(popover): add props table to docz

* refactor: move util and helper methods to common utils

* feat(popover): simplify the implementation of popover

* feat(popover): remove unneeded comments

* feat(popover): add aria attributes, describe placements in props table

* feat(popover): change variable name for popover content state reference

* Update src/components/Popover/docs/Popover.mdx

* feat(popover): fix some of the docs texts

* feat(popover): update useEffect with openByDefault

* feat(popover): remove useStateWithTimeout hook

* feat: popover (#234)

* feat(popover): add popover component to wave

* feat(popover): add props table to docz

* refactor: move util and helper methods to common utils

* feat(popover): simplify the implementation of popover

* feat(popover): remove unneeded comments

* feat(popover): add aria attributes, describe placements in props table

* feat(popover): change variable name for popover content state reference

* Update src/components/Popover/docs/Popover.mdx

Co-authored-by: martimalek <46452321+martimalek@users.noreply.github.com>

* feat(popover): fix some of the docs texts

* feat(popover): update useEffect with openByDefault

* feat(popover): remove useStateWithTimeout hook

Co-authored-by: Ján Hamara <jan.hamara@free-now.com>
Co-authored-by: Jan Hamara <hamara.jan18@gmail.com>

* Use service user's token

* test another token

* Another try

* Revert to github token

* chore(release): 1.24.0 [skip ci]

## [1.24.0](v1.23.0...v1.24.0) (2022-06-02)

### Features

* Add Popover component to wave ([#230](#230)) ([0c49ab3](0c49ab3))
* popover ([#234](#234)) ([8e4075b](8e4075b))

* docs: add JanHamara as a contributor for code, doc, review (#236)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* fix: adding layout to the compose styles (#233)

* chore(release): 1.24.1 [skip ci]

### [1.24.1](v1.24.0...v1.24.1) (2022-06-03)

### Bug Fixes

* adding layout to the compose styles ([#233](#233)) ([48af1d1](48af1d1))

* docs: add div-Leo as a contributor for code, doc, bug, review (#243)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* docs: add rafael-sepeda as a contributor for design, blog (#244)

* improvement: adding bugs and PRs to Lloyd's contributions readme section (#235)

Co-authored-by: Lloyd Francis <lloydaf@gmail.com>

* fix: export popover component in components index (#246)

Authored-by: Martí Malek <marti.malek@free-now.com>

* chore(release): 1.24.2 [skip ci]

### [1.24.2](v1.24.1...v1.24.2) (2022-06-08)

### Bug Fixes

* export popover component in components index ([#246](#246)) ([0def6b8](0def6b8))

* fix: giving singlevalue full max width to override the selectlist styles (#248)

* feat: add InfoBanner component (#225)

* feat: initial InfoBanner version with limited variants

* feat: add infobanner with all the variants

* test: cover different variants with tests

* docs: add examples and combinations for InfoBanner

* docs: improve the basic description of the InfoBanner

* chore: clean unnused component

* refactor: use radii and Spaces instead of hard coded values

* feat: add better accessibility through setting a role attribute

* feat: align infobanner text to the left

* feat: export InfoBanner from components index

* chore: update lock file

Co-authored-by: Martí Malek <marti.malek@free-now.com>
Co-authored-by: Nikolai Lopin <nikolai.lopin@mytaxi.com>

* chore(release): 1.25.0 [skip ci]

## [1.25.0](v1.24.2...v1.25.0) (2022-06-13)

### Features

* add InfoBanner component ([#225](#225)) ([e434f5a](e434f5a))

### Bug Fixes

* giving singlevalue full max width to override the selectlist styles ([#248](#248)) ([115ae70](115ae70))

* fix: window is undefined error in next.js projects

the issue is solved by updating `react-window-select` library to v4

The update brought some follow-up changes described in the pull request #222

* chore(release): 1.25.1 [skip ci]

### [1.25.1](v1.25.0...v1.25.1) (2022-06-16)

### Bug Fixes

* window is undefined error in next.js projects ([b89bfc9](b89bfc9)), closes [#222](#222)

* docs: remove the experimental label for table (#255)

Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
Co-authored-by: Lloyd Francis <lloydaf@gmail.com>
Co-authored-by: David Barrera <dccamilo17@gmail.com>
Co-authored-by: David Barrera <d.barrera@mytaxi.com>
Co-authored-by: Nikolai Lopin <nikolai.lopin@mytaxi.com>
Co-authored-by: Jonathan Trujillo <313951+jonotrujillo@users.noreply.github.com>
Co-authored-by: Leonardo <leonardo.divittorio@live.it>
Co-authored-by: Leonardo Di Vittorio <leo@MacBook-Pro-de-Leonardo.local>
Co-authored-by: Vinayaka Hegde <38563350+Vinayaka2k@users.noreply.github.com>
Co-authored-by: Nikolai Lopin <nikolai.lopin@free-now.com>
Co-authored-by: Martí Malek <marti.malek@free-now.com>
Co-authored-by: Vitaly Baev <ping@baev.dev>
Co-authored-by: Jan Hamara <hamara.jan18@gmail.com>
Co-authored-by: Ján Hamara <jan.hamara@free-now.com>
Co-authored-by: Leonardo Di Vittorio <leonardo.divittorio@Leonardos-MacBook-Pro.local>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
github-actions bot pushed a commit that referenced this pull request Aug 20, 2022
## [2.1.0-next.2](v2.1.0-next.1...v2.1.0-next.2) (2022-08-20)

### Bug Fixes

* adding disabled state for datepicker ([#181](#181)) ([313f424](313f424))
* conflicts between next and main ([#257](#257)) ([0a103ef](0a103ef)), closes [#181](#181) [#183](#183) [#172](#172) [#172](#172) [#185](#185) [#185](#185) [#193](#193) [#193](#193) [#170](#170) [#170](#170) [#196](#196) [#190](#190) [#190](#190) [#200](#200) [#198](#198) [#200](#200) [#200](#200) [#206](#206) [#206](#206) [#208](#208) [#208](#208) [#201](#201) [#201](#201) [#214](#214) [#223](#223) [#221](#221) [#228](#228) [#228](#228) [#231](#231) [#220](#220) [#220](#220) [#230](#230) [#234](#234) [#230](#230) [#234](#234) [#236](#236) [#233](#233) [#233](#233) [#243](#243) [#244](#244) [#235](#235) [#246](#246) [#246](#246) [#248](#248) [#225](#225) [#225](#225) [#248](#248) [#222](#222) [#222](#222) [#255](#255)
* conflicts between next and main v2 ([#281](#281)) ([bec6bdc](bec6bdc))
@github-actions
Copy link
Contributor

🎉 This PR is included in version 3.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Headline: make size a responsive property
3 participants