Giter Club home page Giter Club logo

Comments (2)

nandorojo avatar nandorojo commented on September 23, 2024

I think I know a simpler solution to this. Just use a static breakpoints variable that gets mutated in render code of the provider (if it's in your theme.) This way we can access the static variable globally. It's important that this doesn't change on the fly, but I don't see why anyone would change their breakpoints, so that should work.

// breakpoints.ts
export let breakpoints = [...default ones here]
export const editBreakpoints = (newBreakpoints) => (breakpoints = newBreakpoints)

// in DripsyProvider's render
if ('breakpoints' in theme && theme.breakpoints !== breakpoints) {
  editBreakpoints(theme.breakpoints)
}

The provider code should run before any other dripsy components or functions, so that should suffice.

from dripsy.

nandorojo avatar nandorojo commented on September 23, 2024

Okay, I think I thought of a simpler solution. At the root of your app, just do this, before importing any Dripsy code:

// App.js
import { setBreakpoints } from 'dripsy'

setBreakpoints([400, 792, 968, 1200]) // replace with your custom breakpoints

import { DripsyProvider } from 'dripsy'

Please let me know if this works if you come across it! I can't guarantee it will, since I'm not fully sure what order the breakpoints on web get created in with fresnel. It's possible it won't, but we'll see. This is currently an experimental feature.

from dripsy.

Related Issues (20)

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.