Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue support #273

Open
egoist opened this issue Nov 7, 2018 · 8 comments
Open

Vue support #273

egoist opened this issue Nov 7, 2018 · 8 comments
Labels
cat: extend support 🤝 Support for a new bundler/platform feature: approved ✅ New feature that has been approved needs: help 🆘 Help is needed priority: low 📉 Something nice to have status: up for grabs 🙏 research is done and issue is ready to be grabbed

Comments

@egoist
Copy link

egoist commented Nov 7, 2018

Do you want to request a feature or report a bug?
feature

What is the current behavior?
There's only styled for React, I'm trying to work on a Vue.js integration but

const isImportingModule = value =>
// If the value is an exact match, assume it imports the module
value === source ||
// Otherwise try to resolve both and check if they are the same file
resolveFromFile(value) ===
// eslint-disable-next-line no-nested-ternary
(source === 'linaria'
? require.resolve('../index')
: source === 'linaria/react'
? require.resolve('../react/')
: resolveFromFile(source));
makes it impossible

Solutions

  1. somehow change the code above to allow importing styled from other modules like vue-linaria
  2. or release built-in support for Vue at linaria/vue 😅
@eatsjobs
Copy link

Maybe you can just do something like that?
data: { activeClass: csscolor: green;, errorClass: csscolor: red;`
}

` I don't know if that works but should be. [https://vuejs.org/v2/guide/class-and-style.html#ad](https://vuejs.org/v2/guide/class-and-style.html#ad)

@egoist
Copy link
Author

egoist commented Nov 12, 2018

@eatsjobs sure we can do that, but I mean the styled component support.

@eatsjobs
Copy link

Yeah I understood. but I don't think it's in the 1.0 roadmap so I don't think you can have it soon

@egoist
Copy link
Author

egoist commented Nov 12, 2018

why though 😂 it isn't hard right? just allow the babel plugin to transform styled that's imported from other libs.

@zamotany
Copy link
Contributor

@egoist We are happy to accept a PR with Vue support, we are fine with both integrating Vue inside linaria itself (linaria/vue) or changing the mentioned code. The third option is to add linaria/vue file which will require and export vue-linaria.

@pbitkowski pbitkowski added feature: proposal 💬 New feature proposal that needs to be discussed needs: help 🆘 Help is needed labels May 16, 2019
@jayu jayu added feature: approved ✅ New feature that has been approved priority: low 📉 Something nice to have status: up for grabs 🙏 research is done and issue is ready to be grabbed and removed feature: proposal 💬 New feature proposal that needs to be discussed labels Apr 1, 2020
@jayu jayu added the cat: extend support 🤝 Support for a new bundler/platform label Apr 28, 2020
@vinicius73
Copy link

@egoist are you working on this?

@egoist
Copy link
Author

egoist commented May 19, 2020

@vinicius73 No but I made https://github.com/egoist/styled-vue which is pretty much linaria for Vue a while ago

@dword-design
Copy link
Contributor

dword-design commented Jul 18, 2021

In case it's interesting for you, I had a Nuxt module lying around for some time integrating Linaria. I open-sourced it in case it's interesting for someone. It works for JSX, and you can pass the generated class to a Vue template, but it's not possible to directly call the css literal in the template.

Install it via npm install nuxt-linaria.

Then add it to your Nuxt config:

// nuxt.config.js

export default {
  modules: [
    'nuxt-linaria',
  ],
}

Usage with JSX:

<script>
import { css } from 'linaria'

export default {
  render: h => <div class={css`background: red`}>Hello world</div>,
}
</script>

Usage within a template:

<template>
  <div :class="style">Hello world</div>
</template>
<script>
import { css } from 'linaria'

export default {
  computed: {
    style: () => css\`background: red\`,
  },
}
</script>

Let me know if this is helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat: extend support 🤝 Support for a new bundler/platform feature: approved ✅ New feature that has been approved needs: help 🆘 Help is needed priority: low 📉 Something nice to have status: up for grabs 🙏 research is done and issue is ready to be grabbed
Projects
None yet
Development

No branches or pull requests

7 participants