GithubHelp home page GithubHelp logo

style-bubble's Introduction

StyleBubble: Use new styled components inside old codebases in splendid isolation

Problem statement

You're starting to introduce styled-components to an existing React codebase that already has quite a lot of CSS/SASS/postCSS. Your styled components are lovely, but they keep going askew because of inherited or top-level element styles. So you have empty wrapper tags to escape CSS rules, or manually set unset in a lot of places, or use all at various levels in subtle and hard-to-reason about ways.

In any case, you will end up with with very specific properties and undocumented interactions that will become tomorrow's mysterious layout tech debt. Or you could use a tiny component with zero nonpeer-dependencies that helps you create the styles you need in the present without creating problems in the future.

Using StyleBubble

npm i style-bubble
#or
yarn add style-bubble
import React from 'react';
import StyleBubble from 'style-bubble';

// deep in the bowels of a legacy enterprise app...
<main className="enormous-page-legacy-styling-that-your-team-does-not-own">
    <section className="foo pony bar baz some__sass__from__2014">
        <StyleBubble resetType="initial">
            <MyNewIsolatedWidget/>
        </StyleBubble>
    </section>
</main>

Less time spent sifting through the ruins of a forgotten styling civilization is also less time spent falling into their traps.

Remember that StyleBubble is designed to protect you from inadvertent inheritance. If you actually do want to inherit some things, StyleBubble is best paired with a ThemeProvider below it.

API

resetType. Functionality and browser support are as defined by the CSS all spec, defaults to initial.

style-bubble's People

Contributors

ddunc avatar jdvorak avatar

Watchers

James Cloos avatar  avatar

Forkers

jdvorak

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.