Skip to content

Commit eb0fefc

Browse files
committed
add tailwind CSS + petal.build components for #220
1 parent c7ce1ff commit eb0fefc

File tree

9 files changed

+152
-7
lines changed

9 files changed

+152
-7
lines changed

BUILDIT.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,45 @@ it in **30 minutes**. 🏁
1515

1616
</div>
1717

18-
# TODO: fill-in the gaps during the [Rebuild `#207`](https://github.com/dwyl/auth/issues/207)
18+
- [Build Log 👩‍💻](#build-log-)
19+
- [TODO](#todo)
20+
- [1. Setup the `auth` App](#1-setup-the-auth-app)
21+
- [1. Add Tailwind](#1-add-tailwind)
22+
- [1.6 `Petal.build` Components](#16-petalbuild-components)
23+
- [1.7 `mix format`](#17-mix-format)
24+
- [ERD `before` adding `groups`](#erd-before-adding-groups)
25+
- [10. Groups](#10-groups)
26+
- [10.1 Create Schema](#101-create-schema)
27+
- [10.2 _Test_ Groups Schema](#102-test-groups-schema)
28+
- [10.3 Create `LiveView` for `groups`](#103-create-liveview-for-groups)
29+
- [10.4 Update `router.ex`](#104-update-routerex)
30+
- [TODO: Add Screenshot of Groups Live Page!](#todo-add-screenshot-of-groups-live-page)
31+
- [10.5 Update Tests](#105-update-tests)
32+
- [10.6 Group _Members_](#106-group-members)
33+
34+
<br />
35+
36+
# TODO
37+
38+
We will fill-in the gaps during the [Rebuild `#207`](https://github.com/dwyl/auth/issues/207)
1939

2040
For now I'm just adding the parts that are being added to the "old"
2141
version of **`auth`** so that we can _easily_ re-create them in the re-build.
2242

2343

24-
## 1.6 Petal.build Components
44+
# 1. Setup the `auth` App
45+
46+
## 1. Add Tailwind
47+
48+
Follow the instructions in:
49+
https://github.com/dwyl/learn-tailwind#part-2-tailwind-in-phoenix
50+
51+
52+
## 1.6 `Petal.build` Components
2553

2654
https://petal.build/components/
2755

28-
# 1.7 `mix format`
56+
## 1.7 `mix format`
2957

3058
See: https://github.com/dwyl/mvp/issues/183
3159

assets/css/app.css

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
@import "tailwindcss/base";
2+
@import "tailwindcss/components";
3+
@import "tailwindcss/utilities";
4+
15
/* This file is for your main application css. */
26

37
/* @import "./phoenix.css"; */
@@ -54,3 +58,46 @@
5458
display: block;
5559
margin: -1rem 0 2rem;
5660
}
61+
62+
.select-wrapper select {
63+
@apply text-sm border-gray-300 rounded-md shadow-sm disabled:bg-gray-100 disabled:cursor-not-allowed focus:border-primary-500 focus:ring-primary-500 dark:border-gray-600 dark:focus:border-primary-500 dark:bg-gray-800 dark:text-gray-300 focus:outline-none ;
64+
}
65+
66+
label.has-error:not(.phx-no-feedback) {
67+
@apply !text-red-900 dark:!text-red-200;
68+
}
69+
70+
textarea.has-error:not(.phx-no-feedback), input.has-error:not(.phx-no-feedback), select.has-error:not(.phx-no-feedback) {
71+
@apply !border-red-500 focus:!border-red-500 !text-red-900 !placeholder-red-700 !bg-red-50 dark:!text-red-100 dark:!placeholder-red-300 dark:!bg-red-900 focus:!ring-red-500;
72+
}
73+
74+
input[type=file_input].has-error:not(.phx-no-feedback) {
75+
@apply !border-red-500 !rounded-md focus:!border-red-500 !text-red-900 !placeholder-red-700 !bg-red-50 file:!border-none dark:!border-none dark:!bg-[#160B0B] dark:text-red-400;
76+
}
77+
78+
input[type=checkbox].has-error:not(.phx-no-feedback) {
79+
@apply !border-red-500 !text-red-900 dark:!text-red-200;
80+
}
81+
82+
input[type=radio].has-error:not(.phx-no-feedback) {
83+
@apply !border-red-500;
84+
}
85+
86+
/* Modal animation */
87+
.animate-fade-in-scale {
88+
animation: 0.2s ease-in 0s normal forwards 1 fade-in-scale-keys;
89+
}
90+
91+
.animate-fade-in {
92+
animation: 0.2s ease-out 0s normal forwards 1 fade-in-keys;
93+
}
94+
95+
@keyframes fade-in-scale-keys{
96+
0% { scale: 0.95; opacity: 0; }
97+
100% { scale: 1.0; opacity: 1; }
98+
}
99+
100+
@keyframes fade-in-keys{
101+
0% { opacity: 0; }
102+
100% { opacity: 1; }
103+
}

assets/js/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// We import the CSS which is extracted to its own file by esbuild.
22
// Remove this line if you add a your own CSS build pipeline (e.g postcss).
3-
import "../css/app.css"
43

54
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
65
import "phoenix_html"

assets/tailwind.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// See the Tailwind configuration guide for advanced usage
2+
// https://tailwindcss.com/docs/configuration
3+
4+
const plugin = require('tailwindcss/plugin');
5+
const colors = require("tailwindcss/colors");
6+
7+
module.exports = {
8+
content: [
9+
'./js/**/*.js',
10+
'../lib/*_web.ex',
11+
'../lib/*_web/**/*.*ex',
12+
"../deps/petal_components/**/*.*ex",
13+
],
14+
theme: {
15+
extend: {
16+
colors: {
17+
primary: colors.blue,
18+
secondary: colors.pink,
19+
},
20+
},
21+
},
22+
plugins: [
23+
require('@tailwindcss/forms'),
24+
plugin(({addVariant}) => addVariant('phx-no-feedback', ['&.phx-no-feedback', '.phx-no-feedback &'])),
25+
plugin(({addVariant}) => addVariant('phx-click-loading', ['&.phx-click-loading', '.phx-click-loading &'])),
26+
plugin(({addVariant}) => addVariant('phx-submit-loading', ['&.phx-submit-loading', '.phx-submit-loading &'])),
27+
plugin(({addVariant}) => addVariant('phx-change-loading', ['&.phx-change-loading', '.phx-change-loading &']))
28+
]
29+
}

config/config.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ config :esbuild,
4545

4646
config :auth_plug,
4747
api_key: System.get_env("AUTH_API_KEY")
48+
49+
config :tailwind,
50+
version: "3.2.0",
51+
default: [
52+
args: ~w(
53+
--config=tailwind.config.js
54+
--input=css/app.css
55+
--output=../priv/static/assets/app.css
56+
),
57+
cd: Path.expand("../assets", __DIR__)
58+
]

lib/auth_web.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ defmodule AuthWeb do
8080
quote do
8181
# Use all HTML functionality (forms, tags, etc)
8282
use Phoenix.HTML
83+
use PetalComponents
8384

8485
# Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)
8586
import Phoenix.LiveView.Helpers
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
<!-- LiveView Layout File -->
2-
<body>
2+
<.container class="my-10">
3+
<.alert
4+
color="info"
5+
class="mb-5"
6+
label={live_flash(@flash, :info)}
7+
phx-click="lv:clear-flash"
8+
phx-value-key="info"
9+
/>
10+
11+
<.alert
12+
color="danger"
13+
class="mb-5"
14+
label={live_flash(@flash, :error)}
15+
phx-click="lv:clear-flash"
16+
phx-value-key="error"
17+
/>
18+
319
<%= @inner_content %>
4-
</body>
20+
</.container>

mix.exs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ defmodule Auth.Mixfile do
8888
# Useful functions: https://github.com/dwyl/useful
8989
{:useful, "~> 1.0.8"},
9090

91+
# Tailwind CSS
92+
# See: https://github.com/dwyl/learn-tailwind
93+
{:tailwind, "~> 0.1", runtime: Mix.env() == :dev},
94+
95+
# https://petal.build/components
96+
{:petal_components, "~> 0.18"},
97+
9198
# Ping to Wake Heroku Instance: https://github.com/dwyl/ping
9299
{:ping, "~> 1.1.0"},
93100

@@ -116,7 +123,11 @@ defmodule Auth.Mixfile do
116123
# See the documentation for `Mix` for more info on aliases.
117124
defp aliases do
118125
[
119-
"assets.deploy": ["esbuild default --minify", "phx.digest"],
126+
"assets.deploy": [
127+
"tailwind default --minify",
128+
"esbuild default --minify",
129+
"phx.digest"
130+
],
120131
c: ["coveralls.html"],
121132
"ecto.setup": ["ecto.create --quiet", "ecto.migrate --quiet", "seeds"],
122133
"ecto.reset": ["ecto.drop", "ecto.setup"],

mix.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"floki": {:hex, :floki, "0.33.1", "f20f1eb471e726342b45ccb68edb9486729e7df94da403936ea94a794f072781", [:mix], [{:html_entities, "~> 0.5.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm", "461035fd125f13fdf30f243c85a0b1e50afbec876cbf1ceefe6fddd2e6d712c6"},
3232
"gettext": {:hex, :gettext, "0.19.1", "564953fd21f29358e68b91634799d9d26989f8d039d7512622efb3c3b1c97892", [:mix], [], "hexpm", "10c656c0912b8299adba9b061c06947511e3f109ab0d18b44a866a4498e77222"},
3333
"hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~>2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"},
34+
"heroicons": {:hex, :heroicons, "0.5.1", "cca0dcca07af5f74d8a7d111e40418d3615d65e6773c0ea10e20cef070fd30aa", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.18.2", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "4b096d0a1d50e9054df9b12cc637c9f65c3972ff086791d3f2d1846f0653117e"},
3435
"html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"},
3536
"html_sanitize_ex": {:hex, :html_sanitize_ex, "1.4.2", "c479398b6de798c03eb5d04a0a9a9159d73508f83f6590a00b8eacba3619cf4c", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm", "aef6c28585d06a9109ad591507e508854c5559561f950bbaea773900dd369b0e"},
3637
"httpoison": {:hex, :httpoison, "1.8.2", "9eb9c63ae289296a544842ef816a85d881d4a31f518a0fec089aaa744beae290", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "2bb350d26972e30c96e2ca74a1aaf8293d61d0742ff17f01e0279fef11599921"},
@@ -47,6 +48,7 @@
4748
"mochiweb": {:hex, :mochiweb, "2.22.0", "f104d6747c01a330c38613561977e565b788b9170055c5241ac9dd6e4617cba5", [:rebar3], [], "hexpm", "cbbd1fd315d283c576d1c8a13e0738f6dafb63dc840611249608697502a07655"},
4849
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
4950
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
51+
"petal_components": {:hex, :petal_components, "0.18.5", "f7abd370d179e8ab1eff491a7a85526984ead78b41190b03f6ec5df04932cdbf", [:mix], [{:heroicons, "~> 0.5.0", [hex: :heroicons, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_ecto, "~> 4.4", [hex: :phoenix_ecto, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.18.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "d38982b0e9fa39884cfaf5e49bdc77a6be16b17b73fc19001b2a27fe4b672dca"},
5052
"phoenix": {:hex, :phoenix, "1.6.14", "57678366dc1d5bad49832a0fc7f12c2830c10d3eacfad681bfe9602cd4445f04", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d48c0da00b3d4cd1aad6055387917491af9f6e1f1e96cedf6c6b7998df9dba26"},
5153
"phoenix_ecto": {:hex, :phoenix_ecto, "4.4.0", "0672ed4e4808b3fbed494dded89958e22fb882de47a97634c0b13e7b0b5f7720", [:mix], [{:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "09864e558ed31ee00bd48fcc1d4fc58ae9678c9e81649075431e69dbabb43cc1"},
5254
"phoenix_html": {:hex, :phoenix_html, "3.2.0", "1c1219d4b6cb22ac72f12f73dc5fad6c7563104d083f711c3fcd8551a1f4ae11", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "36ec97ba56d25c0136ef1992c37957e4246b649d620958a1f9fa86165f8bc54f"},
@@ -64,6 +66,7 @@
6466
"sobelow": {:hex, :sobelow, "0.11.1", "23438964486f8112b41e743bbfd402da3e5b296fdc9eacab29914b79c48916dd", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "9897363a7eff96f4809304a90aad819e2ad5e5d24db547af502885146746a53c"},
6567
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
6668
"stream_data": {:hex, :stream_data, "0.5.0", "b27641e58941685c75b353577dc602c9d2c12292dd84babf506c2033cd97893e", [:mix], [], "hexpm", "012bd2eec069ada4db3411f9115ccafa38540a3c78c4c0349f151fc761b9e271"},
69+
"tailwind": {:hex, :tailwind, "0.1.9", "25ba09d42f7bfabe170eb67683a76d6ec2061952dc9bd263a52a99ba3d24bd4d", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "9213f87709c458aaec313bb5f2df2b4d2cedc2b630e4ae821bf3c54c47a56d0b"},
6770
"telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"},
6871
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
6972
"telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},

0 commit comments

Comments
 (0)