Comments (14)
@neilberkman just to make it clear, you should be able to use "clipboard__icon"
today if you write the key as a string, so:
<div class={{ "clipboard__icon" => true }}>
should be translated to:
<div class="clipboard__icon">
Pay attention that "clipboard__icon": true
is different from "clipboard__icon" => true
. In the former the key is an atom
, in the latter, the key is a string.
In case the above doesn't work as expected, we have a bug so please let me know.
from surface.
Personally I quite like the auto-conversion feature, and I think it makes perfect sense when you think about conventions around CSS classes. As long as it's called out in the documentation clearly I think it's fine.
Alternatively you could use underscore-case -> kebab-case conversion instead; if anything I think that makes even more sense since you're going from idiomatic elixir naming to idiomatic CSS naming.
from surface.
All right, folks!
I've decided to drop the automatic camel-to-kebab conversion. For those that like this feature, I'm willing to find another way to provide similar behaviour by maybe adding a built-in function or some kind of modifier to make its use explicit.
The next alpha version should be released already without it.
Thank you all for the fantastic feedback!
from surface.
Another option would be to make this a config setting, or something passed as a __using__
option? e.g:
use Surface, convert_classes: false
from surface.
for what it's worth, I prefer to just specify the css class name without any conversion
the underscore to kebab case conversion would cause issues with BEM style CSS if i'm not mistaking what you're suggesting
from surface.
the underscore to kebab case conversion would cause issues with BEM style CSS if i'm not mistaking what you're suggesting
We're encountering this now: #50 (comment)
from surface.
I recognize that those names wouldn't be idiomatic elixir; however I feel like the edge cases get fairly extensive when we start converting things; and as the names are technically css and not elixir the non-idiomaticness doesn't bother me too much
from surface.
@msaraiva Speaking to your point about feature causing confusion, I've had to pull up the docs to check how to do it multiple times because it doesn't feel natural to me. So I'm sympathetic to that concern.
I do like the ability to include a class with a boolean value (or function call) so I want the ability to remain, but the implementation and API are fine to change for me. I'm not using any CSS libraries that have issues with it.
from surface.
Another option would be to make this a config setting
@wrren I would avoid a config for that as much as possible since it doesn't solve the issue of confusion. I'm inclined to drop the feature unless we can make sure that improving the docs/examples will be enough.
I'll merge #51 in the meantime and wait for more feedback to make a final decision about dropping the feature.
Thank you all for your comments ❤️
from surface.
Personally I didn't used the auto-convert. I think the argument to support isn't sufficient. There are many ways to write css class names, Im using tailwindcss for example. So to support one way of writing class names that cause so many problems seems unnecessary. Hope my input helps :)
On related topic, can I do something like that?
some_classes = "class_1 class_2 .."
<div class={{ ^some_classes => true }}>
from surface.
@mazz-seven thanks for the input.
Regarding the suggested code, it's currently not possible. The closest thing I can come up with, in case you'll alway use true
, is:
some_classes = [:class_1, :class_2, ...]
<div class={{ some_classes }}>
However, I'm not sure which other cases you want to cover, so this is probably not what you're looking for.
from surface.
I'd vote for no automatic conversion.
Absinthe has auto camelCase conversion for graphql queries and there have been many questions from people wondering what happened to their field names. Absinthe allows users to override it, and have good docs, but it has still surprised many people.
I understand why they did it, and appreciate it in their case.. but I would not enjoy it as much for css... I'd just prefer it to be what I think it is.
from surface.
I'm in favor of not automatically kebabing or to at least provide an escape hatch. I am using an existing style sheet that I'm writing components for and it mixes use of kebab and camel cases.
from surface.
Resolved in #62. Thanks @zamith!
from surface.
Related Issues (20)
- Setting which modules can pass context values outside of config
- Erlang Error in Elixir Language Server with Surface HOT 1
- [Using a plugin] Scoped CSS changes require two page reloads. HOT 1
- inputs_for/3 warning HOT 1
- Warnings on Select component with disabled property
- Props missing inside `handle_event()` `socket.assigns` map. HOT 3
- mix surface.init: no function clause matching in Sourceror.Zipper.down/1 HOT 3
- Support for LiveViewNative? HOT 5
- Submitted forms don't carry the "submitter" attribute
- Surface CSS scoping attributes don't work when root component is a component
- When using :on-click={"name", target="#target_id"} I cannot seem to get a sibling to target another sibling node that is rendered in the same parent. HOT 1
- Compatibility with LiveView 0.20 HOT 7
- Question: How would you make the sample tab component to use svg icons instead of font icons HOT 4
- Elixir 1.16: negative steps are not supported in String.slice/2, pass 1..-2//1 instead
- Malformed HTML when using LiveRedirect with another component inside HOT 1
- Mix.env() usage can cause troubles in release HOT 2
- Question: Form example on latest version HOT 2
- error: module Surface.Components.Form.Inputs is not loaded and could not be found. This may be happening because the module you are trying to load directly or indirectly depends on the current module<Description> HOT 1
- Surface LiveComponent raise single static root error if render root is Form Component HOT 2
- error: undefined function date_select/3 in v0.11.4 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from surface.