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.

Usage of css helper function

See original GitHub issue

Based on a conversation over at https://github.com/styled-components/vim-styled-components/pull/30 I wanted to talk a bit about the purpose of the css helper mixin.

The current documentation states

css A helper function to generate CSS from a template literal with interpolations. You need to use this if you return a template literal with interpolations inside an interpolation. (This is due to how tagged template literals work)

If you’re just returning a normal string you do not need to use this.

Based on the conversation generated in the above PR it seems this description is no longer accurate? And the css helper is intended to be used whenever the user breaks out of an interpolation.

This feels like a sledgehammer solution to the problem when education would be more beneficial.

I feel that the current documentation does a very good job of describing the appropriate use case for the css helper and that the informed developer knows when it’s needed vs. when returning a plain string is acceptable.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kittencommented, Oct 10, 2017

You are on the right track here. Unfortunately we won’t be targeting custom tagged template literals. Maybe we will at some point but for now it seems unlikely.

A future proof implementation would involve turning the input for such a media helper into: media.large(css``) for instance

I’m sure you could also work on a codemod when the time comes. We are just a couple of people with a lot of foundational work to be done until more can start to help and accelerate work on v3

0reactions
mxstbrcommented, Dec 15, 2017

Closing since there’s nothing actionable for us to do here, thanks for forcing us to clarify @Jmeyering!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding css helper function in styled components
A helper function to generate CSS from a template literal with interpolations. You need to use this if you return a template literal...
Read more >
Thank Me Later: Use Styled Components's css helper ...
To solve this, Styled Components added a helper function named simply css that also accepts a tagged template as its parameter. It forwards ......
Read more >
How Writing CSS Helper Classes Improved My Productivity
In short CSS helper classes are a great way to write reusable CSS styles that scale with your project. By using helper classes...
Read more >
Using Helper Classes to DRY and Scale CSS - SitePoint
Helper classes can help remove repetition by creating a set of abstract classes that can be used over and over on HTML elements....
Read more >
Helper Functions - BladewindUI
Very similar to changeCss but this adds or removes CSS classes from an array of CSS elements in the DOM. This targets elements...
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