Skip to content

Instantly share code, notes, and snippets.

@RomanTurner
Last active July 16, 2023 23:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RomanTurner/844659ae270732028db377606164bb77 to your computer and use it in GitHub Desktop.
Save RomanTurner/844659ae270732028db377606164bb77 to your computer and use it in GitHub Desktop.
POC Tailwind + Phlex component.
class StyledComponent < Phlex::HTML
STYLES = {
container: {
xs: "mx-auto max-w-7xl px-6 py-24",
sm: "sm:py-32",
lg: "lg:px-8"
},
get_started: {
xs:
"rounded-md bg-indigo-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm",
hover: "hover:bg-indigo-500",
focus_visible:
"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
}
}
def tw(klass)
{ class: STYLES[klass].values.join(" "), data_class_name: klass}
end
def template
div(class: "bg-white", data_component: self.class) do
div(**tw(:container)) do
h2(
class: "text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl"
) do
plain "Boost your productivity"
br
plain "Start using our app today."
end
div(class: "mt-10 flex items-center gap-x-6") do
a(href: "#", **tw(:get_started)) { "Get started" }
a(
href: "#",
class: "text-sm font-semibold leading-6 text-gray-900"
) do
plain "Learn more"
span(aria_hidden: "true") { " →" }
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment