-
Notifications
You must be signed in to change notification settings - Fork 27
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
Replace Bulma with TailwindCSS #20
Comments
Since phoenix So here are all (for now) the things I want to explore in this project:
I have already discussed some of those items with @davydog187 and I'm glad he's just as excited as I am about this project and will be helping me in this journey. @haubie, @rmayhue, @Menkir and @gdub01 based on the previous discussion, it seems to me you've already played with the Tailwind + Surface combo and experienced some of the challenges we're about to face here. I liked the discussion and ideas that were brought up regarding the ideal API and I think we'll certainly explore them here. So moving on, I'll start with a couple of questions:
|
Hi @msaraiva. Very excited to see parts of your pioneering work and persistence with Surface being imported into the next Phoenix release! I've been playing around with the ideas in the previous discussion including creating some components using them. But I agree that if the goal is to get a rich and slick set of components using Tailwind CSS in a short period of time, wrapping DaisyUI maybe the path. (Plus adding some additional ones like you mentioned for layouts.) And using the name It looks like they had similar to goals to what I was exploring in how to have some sensible defaults, but still allow component users to customise through applying a theme definition or overriding classes on a specific component. The way they've done it looks pretty nice :-) I also really really like the idea of number 5 in terms of future proofing any components built and not have to rebuilt components from scratch if that new amazing CSS framework comes along! In terms of an API, for the styling part of that, if the goal is targeting people who use Tailwind on a regular basis, I'm thinking that Tailwind naming conventions could be used for prop names. e.g. if there was a prop for
I guess one issue with this is that is it could create many props on a component, rather than a single class prop. But the good thing with this way is that component user only has to override the props they want. And if DaisyUI is being used, those additional props are probably only needed for reaching into some of those deeper classes - e.g. with the DaisyUI avatar component, the top-level div would have the
In the render function:
So the component user might just do:
And if they only wanted to change the shape, it would be:
Or add some padding:
Another thought on API, for components that link off, like a menu, instead of a singular
This is just opinion based my my experimentation and I'm sure others will have views as well! |
I am glad that there is more movement in this project. Grouping Tailwind classes into DaisyUi components is a very good start for an out of the box solution. There is no license constraint now and you can provide a library with strong defaults. The question if the project should be called surface_tailwind or surface_daisyui implies for me on the question if also a standard API should be provided, so that one can write own components against this API. If not then surface_daisyui, otherwise surface_tailwind. However, a standard API is not exactly easy to develop, since components can become indefinitely complex. The way to configure a component as @haubie suggested works only for flat components. So rather for absolute basic components. For bigger things like tables it needs more configuration. <div class={@width}>
<div class={@bg-color}>
<div class={... different bg-color ...}
</div>
</div> The tight coupling of design and form (html-divs etc.) makes it hard to define the properties. What works better is the separation of design and form like DaisyUi does. You introduce your own classes that are configurable to a certain degree. <MyComp type="danger"> defmodule MyComp do
use Surface.Component
prop type, :string, default: "default", values: ~w(default danger info success warning)
def render(assigns) do
<div class="foo" data-type={@type}>
<div class="inner-foo" data-type={@type}>
<div class="baz" data-type={@type}>
...
</div>
</div>
</div>
end
end
.foo data[type="danger"]{
@apply text-red-200 border-2 border-red-500;
}
.inner-foo data[type="danger"]{
@apply bg-red-50
}
.baz {
@apply text-sm;
}
.baz data[type="danger"]{
@apply text-red-900
}
Another advantage of this method is that the HTML is not bloated. Especially in the Inspector the html trees become much leaner. @msaraiva on point 4: What exactly do you mean by unavoidable Js stuff? I had used Alpine for exactly one reason: Animations. LiveView/Surface exists for the very reason that you need little to no JS anymore. Unless you want to link your application to a JS application. But there are hooks for that. |
@haubie and @Menkir, thanks for your inputs.
I have mixed feelings about this. I believe one of the main reasons that drove people to create all those
I totally agree. It's a hard problem to solve. I'm not sure we'll be able to find a solution for that but we can certainly try :)
I guess "unavoidable" was a bad choice of word :) What I mean it that besides the obvious cases where we need JS (animations, drag and drop, etc.), there are cases when we don't need server events to perform some basic user interactions. Take this Tabs component, for example. Currently, whenever you click on a tab, an event is sent to the server. That would make sense if we needed to load the tab's content dynamically on each click but in many cases, we don't. We could just bring everything and use JS to show/hide the tabs. This may not be a problem for most components but depending on the amount of data that might be exchanged, it just adds unnecessary server round trips. We can still use vanilla JS to handle that too but with alpine it's just much easier and clean. Basically, whenever a component requires some state on the client, Alpine really shines. I still haven't decided if we should use alpine or not but I think it might be worth to explore the possibility. |
Interesting discussion. Comfortable with the thoughts above including the use of AlpineJS.
I guess we could take this a bit more iteratively and aim for a less 'customisable' release initially, with a minimal API, until we settle on a nice way to handle it? Although there is probably a 'common sense' test that could be applied to each component as to what parts we'd like to expose in its own prop? (e.g. just to use the basic avatar example above I'm thinking size, shape, image and any action would be the minimum and all optional?) If Surface Catalogue is the fist project using them, then I think you may end up identifying the pain points and API needs @msaraiva as you're using it! Let me know if I can contribute in some way. I'm happy to start wrapping some DaisyUI with Surface as an initial parse through. That may help with design decisions around the API as well. |
With regards to DaisyUI.. the upside is it's faster to develop if we use it directly. Perhaps we could use a lot of their component-based tailwind classes and html structure to get a jump on things instead of using daisyui directly? They'll be pinned to a tailwind version so they'll be unlikely to change much I don't think. I also like the idea of alpine for things like tabs and dropdowns. |
I hadn't really taken a deeper look at DaisyUI until the last few days. It looks like it's a Tailwind plugin with JavaScript code running behind the scenes during build. I guess there is a concern by using DaisyUI, that we might be coupling ourselves to their specific build tooling, how they have organised their project, etc? So your idea @gdub01 of using their classes and html but not the rest of it (with full acknowledgement) could be a good way to kick off surface_tailwind rather than surface_daisyui? |
Hey yes David thanks that says it perfectly.
I think daisy lets you add a class of 'button' which ultimately ends up
being a list of tailwind classes. So in our case if we had a 'button'
*component* we'd avoid using daisy's 'button' *class*, but rather skip
directly to their list of tailwind classes with full acknowledgement as you
mentioned.
…On Mon, Aug 16, 2021 at 12:21 AM David ***@***.***> wrote:
I hadn't really taken a deeper look at DaisyUI until the last few days. It
looks like it's a Tailwind plugin with JavaScript code running behind the
scenes during build. I guess there is a concern by using DaisyUI, that we
might be coupling ourselves to their specific build tooling, how they have
organised their project, etc?
So your idea @gdub01 <https://github.com/gdub01> of using their classes
and html but not the rest of it (with full acknowledgement) could be a good
way to kick off surface_tailwind rather than surface_daisyui?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAM7F3B4WHRNQPS7Y7YBHZLT5CG4HANCNFSM5A2EMZ2A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Ah you know what I may have over simplified. https://github.com/saadeghi/daisyui/blob/master/src/components/styled/button.css is their styled button component. So there's a little more complexity than just copying a list of tailwind classes I'm learning. |
@gdub01 as far as I could see, they work independent from each other and they are chosen according to the So we could just pick the one we want, which I believe would be the |
Oh yes I think you're right @msaraiva I think the utilities, in the case of the button, have aspects you could argue are better relegated to a theme. ie. if you want rounded buttons, you probably always want rounded buttons.. not sometimes round sometimes square. So the utility classes for buttons may not be as useful. However in the case of the avatars https://github.com/saadeghi/daisyui/blob/master/src/utilities/styled/avatar.css having an online and offline version would be pretty useful. So perhaps we can pick and choose the utility modifiers we'd want to support. The other interesting thing is their use of css variables like so: border-width: var(--border-btn, 1px); I think we'd have to decide how we'd want to set that up as it plays into theming. Perhaps we could have a module that just sets all the variables by passing it a theme object and it sets the variables inside
tags that are rendered on the page inline? |
I want to redesign the UI using TailwindCSS and turn the Catalogue into a official supported tool (not only a prototype). In the process I want to extract the components we need to create here and move them to surface_tailwind so they can be reused in other projects.
The text was updated successfully, but these errors were encountered: