question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Breakpoint aliases does not seem to work with "@chakra-ui/nuxt"

See original GitHub issue

Describe the bug When using “@chakra-ui/nuxt”: “^0.1.0”, I cannot get “aliased” breakpoints to work. Using the array syntax to specify the different properties works as expected. This might be an misconfiguration but I’ve been debugging for a while and I cannot find a solution.

To Reproduce Steps to reproduce the behavior: Setup an nuxt app with @chakra-ui/nuxt and @nuxtjjs/emotion. Add the following snippet to the generated index.vue component in the pages folder: <c-heading :bg={base: 'red.500, md: 'blue.500'}>Chakra UI</c-heading>. The background color of the heading will always be blue.

See example below in “Additional context”

Expected behavior I expect the background color to be red until the md breakpoint is hit, at that point the background should turn blue.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version: 86.0.4240.75

Additional context Attaching an example of the error in an codesandbox.io container where I used the example and changed it to use the “@chakra-ui/nuxt” package. The “Hello chakra-ui/vue” heading has a background that should be red at base resolution and turn blue when the md breakpoint is hit.

https://codesandbox.io/s/chakra-ui-nuxt-demo-forked-ed87w

When I tried to do the same thing using another fork of the chakra-ui-nuxt-demo without installing “@chakra-ui/nuxt” package the breakpoint works as expected:

https://codesandbox.io/s/chakra-ui-nuxt-demo-forked-zuh9h

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
philwolstenholmecommented, Apr 23, 2021

For now, I’ve added this to node_modules/@chakra-ui/nuxt/lib/plugin.js using https://www.npmjs.com/package/patch-package

--- a/node_modules/@chakra-ui/nuxt/lib/plugin.js
+++ b/node_modules/@chakra-ui/nuxt/lib/plugin.js
 
 const theme = <%= JSON.stringify(options.theme, null, 2) %>
 
+const tshirtSizes = ['sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'];
+
+theme.breakpoints.forEach((breakpoint, index) => {
+  theme.breakpoints[tshirtSizes[index]] = breakpoint;
+});
+
 Vue.prototype.$chakra = {
   theme,
   icons: <%= JSON.stringify(options.icons, null, 2) %>
0reactions
philwolstenholmecommented, Apr 23, 2021

I think the issue is that the breakpoint alias information isn’t being copied to the theme object in .nuxt-storybook/chakra.js successfully.

If I manually add these lines to my .nuxt-storybook/chakra.js then the alias and object syntax for classes starts working:

theme.breakpoints.sm = theme.breakpoints[0];
theme.breakpoints.md = theme.breakpoints[1];
theme.breakpoints.lg = theme.breakpoints[2];
theme.breakpoints.xl = theme.breakpoints[3];
theme.breakpoints['2xl'] = theme.breakpoints[4];
theme.breakpoints['3xl'] = theme.breakpoints[5];
theme.breakpoints['4xl'] = theme.breakpoints[6];

(We have overridden the breakpoints to add a few extras)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Responsive Styles - Chakra UI
To make styles responsive, you can use either the array or object syntax. ... You can also define responsive values with breakpoint aliases...
Read more >
How to make a @mixin using variables, so I can call ...
How to make a @mixin using variables, so I can call breakpoints with aliases names? ... I'm building a website with some SASS...
Read more >
Not all custom responsive directives work as expected #776
fxShow.x directives do not seem to fire as expected but I have raised this as a separate issue: fxShow does not seem to...
Read more >
Breakpoint Systems
If a website's responsive design does not align with a certain device ... depend on what breakpoint names are available, we can use...
Read more >
xdebug breakpoint support with lighttpd rewrite/alias?
I seem to be having troubles getting the xdebug to work with ... due to the rewrite rule or the alias, it will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found