Skip to content
This repository was archived by the owner on Jul 9, 2019. It is now read-only.
This repository was archived by the owner on Jul 9, 2019. It is now read-only.

adaptive values #175

@tushar-singh

Description

@tushar-singh

@kylerc here's an idea for more dynamic styling. Need your comment on feasibility/perf (from what I understand it should be possible, with not-so-bad perf hit with debounce on updates)

theme.js:

gutter: {
    base: 15,
    small: 8,
},
adaptiveGutter: {
    updateOn: ['orientationChange', 'resize'],
    value: () => {
        if (window.innerWidth < 600) return { base: 10, small: 6 };
        else return { base: 15, small: 8 };
    }
}

SomeComponent/style.js

padding: theme.adaptiveGutter.base

Automagically updated on orientationChange and resize. Avoids media queries across the board for certain repetitive values (+ free consistency)

There's another way with a function which could theoretically improve performance by letting you know which components exactly use the adaptive values and only update their style. But its more verbose compared to the original method which doesn't require any change in style.js

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions