Resources
20 |-
21 |
- 22 | Guides & Docs 23 | 24 |
- 25 | Source 26 | 27 |
- 28 | v1.5 Changelog 29 | 30 |
├── .formatter.exs ├── .gitignore ├── README.md ├── assets ├── .babelrc ├── css │ ├── app.scss │ └── phoenix.css ├── js │ └── app.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── static │ ├── favicon.ico │ ├── images │ │ └── phoenix.png │ └── robots.txt ├── tailwind.config.js └── webpack.config.js ├── config ├── config.exs ├── dev.exs ├── prod.exs ├── prod.secret.exs ├── runtime.exs └── test.exs ├── lib ├── pwa.ex ├── pwa │ ├── application.ex │ ├── books.ex │ ├── books │ │ └── book.ex │ └── fake_repo.ex ├── pwa_web.ex └── pwa_web │ ├── channels │ └── user_socket.ex │ ├── components.ex │ ├── components │ └── modal.ex │ ├── endpoint.ex │ ├── gettext.ex │ ├── live │ ├── book_live │ │ ├── form_component.ex │ │ ├── form_component.html.leex │ │ ├── index.ex │ │ ├── index.html.leex │ │ ├── show.ex │ │ └── show.html.leex │ ├── live_helpers.ex │ ├── modal_component.ex │ ├── page_live.ex │ └── page_live.html.leex │ ├── router.ex │ ├── telemetry.ex │ ├── templates │ └── layout │ │ ├── app.html.eex │ │ ├── live.html.leex │ │ └── root.html.leex │ └── views │ ├── error_helpers.ex │ ├── error_view.ex │ └── layout_view.ex ├── mix.exs ├── mix.lock ├── priv └── gettext │ ├── en │ └── LC_MESSAGES │ │ └── errors.po │ └── errors.pot └── test ├── pwa_web ├── live │ └── page_live_test.exs └── views │ ├── error_view_test.exs │ └── layout_view_test.exs ├── support ├── channel_case.ex └── conn_case.ex └── test_helper.exs /.formatter.exs: -------------------------------------------------------------------------------- 1 | [ 2 | import_deps: [:phoenix], 3 | inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where 3rd-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Ignore package tarball (built via "mix hex.build"). 23 | pwa-*.tar 24 | 25 | # If NPM crashes, it generates a log, let's ignore it too. 26 | npm-debug.log 27 | 28 | # The directory NPM downloads your dependencies sources to. 29 | /assets/node_modules/ 30 | 31 | # Since we are building assets from assets/, 32 | # we ignore priv/static. You may want to comment 33 | # this depending on your deployment strategy. 34 | /priv/static/ 35 | 36 | .tool-versions -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PWA 2 | 3 | LiveView configured as a Progressive Web Application. 4 | 5 | To start your Phoenix server: 6 | 7 | * Install dependencies with `mix deps.get` 8 | * Install Node.js dependencies with `npm install` inside the `assets` directory 9 | * Start Phoenix endpoint with `mix phx.server` 10 | 11 | Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. 12 | 13 | Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html). 14 | 15 | ## Project Notes 16 | 17 | Created the project using: 18 | 19 | ``` 20 | mix phx.new pwa --live --no-ecto 21 | ``` 22 | 23 | Generated LiveView resource pages 24 | 25 | ``` 26 | mix phx.gen.live Books Book books title:string author:string 27 | ``` 28 | 29 | ## Resources 30 | 31 | ### Project 32 | 33 | - [Sample repo](https://github.com/brainlid/pwa-bookit-sample/) 34 | - 2 branches 35 | - [Commit adding TailwindCSS and Alpine.js](https://github.com/brainlid/pwa-bookit-sample/commit/07bc228338d66a4ac96c80975baa4a8cfd13a82d) 36 | - [Podcast: #021 Tailwind CSS, Alpine.js and LiveView with Patrick Thompson](https://thinkingelixir.com/podcast-episodes/021-tailwind-css-alpine-js-and-liveview-with-patrick-thompson/) - Show notes has lots of great Tailwind and Alpine resources. 37 | 38 | ### PWA Resources 39 | 40 | - [8 Tips to Make Your Website Feel Like an iOS App - YouTube video](https://www.youtube.com/watch?v=KzvK809rl3Q) 41 | - [8 Tips to Make Your Website Feel Like an iOS App - Blog form](https://samselikoff.com/blog/8-tips-to-make-your-website-feel-like-an-ios-app) 42 | - [MDN env(safe-area-inset-*)](https://developer.mozilla.org/en-US/docs/Web/CSS/env()) 43 | - [Google's Progressive Web Apps guide](https://web.dev/progressive-web-apps/) 44 | 45 | ### Understanding the State of the Art 46 | 47 | Deals with platform differences and things like Push Notifications. 48 | 49 | - [The state of PWA support on mobile and desktop in 2020](https://simplabs.com/blog/2020/06/10/the-state-of-pwa-support-on-mobile-and-desktop-in-2020/) 50 | - [Progressive Web Apps: Core Features, Architecture, Pros and Cons](https://www.altexsoft.com/blog/engineering/progressive-web-apps/) 51 | - [What are Progressive Web Application Push Notifications?](https://love2dev.com/pwa/push-notifications/) -------------------------------------------------------------------------------- /assets/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /assets/css/app.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * This injects Tailwind's base styles and any base styles registered by 3 | * plugins. 4 | */ 5 | 6 | /* purgecss start ignore */ 7 | 8 | @tailwind base; 9 | @tailwind components; 10 | 11 | /* purgecss end ignore */ 12 | 13 | @tailwind utilities; 14 | 15 | /** 16 | * Use this directive to control where Tailwind injects the responsive 17 | * variations of each utility. 18 | * 19 | * If omitted, Tailwind will append these classes to the very end of 20 | * your stylesheet by default. 21 | */ 22 | @tailwind screens; 23 | 24 | /* Alpine.js - when first loading a page, hide anything with x-cloak so it won't show then disappear */ 25 | [x-cloak] { 26 | display: none; 27 | } 28 | 29 | /* This file is for your main application css. */ 30 | 31 | 32 | /* 33 | @import "./custom-styles.css"; 34 | */ 35 | 36 | -------------------------------------------------------------------------------- /assets/css/phoenix.css: -------------------------------------------------------------------------------- 1 | /* Includes some default style for the starter application. 2 | * This can be safely deleted to start fresh. 3 | */ 4 | 5 | /* Milligram v1.3.0 https://milligram.github.io 6 | * Copyright (c) 2017 CJ Patoilo Licensed under the MIT license 7 | */ 8 | 9 | *,*:after,*:before{box-sizing:inherit}html{box-sizing:border-box;font-size:62.5%}body{color:#000000;font-family:'Helvetica', 'Arial', sans-serif;font-size:1.6em;font-weight:300;line-height:1.6}blockquote{border-left:0.3rem solid #d1d1d1;margin-left:0;margin-right:0;padding:1rem 1.5rem}blockquote *:last-child{margin-bottom:0}.button,button,input[type='button'],input[type='reset'],input[type='submit']{background-color:#0069d9;border:0.1rem solid #0069d9;border-radius:.4rem;color:#fff;cursor:pointer;display:inline-block;font-size:1.1rem;font-weight:700;height:3.8rem;letter-spacing:.1rem;line-height:3.8rem;padding:0 3.0rem;text-align:center;text-decoration:none;text-transform:uppercase;white-space:nowrap}.button:focus,.button:hover,button:focus,button:hover,input[type='button']:focus,input[type='button']:hover,input[type='reset']:focus,input[type='reset']:hover,input[type='submit']:focus,input[type='submit']:hover{background-color:#606c76;border-color:#606c76;color:#fff;outline:0}.button[disabled],button[disabled],input[type='button'][disabled],input[type='reset'][disabled],input[type='submit'][disabled]{cursor:default;opacity:.5}.button[disabled]:focus,.button[disabled]:hover,button[disabled]:focus,button[disabled]:hover,input[type='button'][disabled]:focus,input[type='button'][disabled]:hover,input[type='reset'][disabled]:focus,input[type='reset'][disabled]:hover,input[type='submit'][disabled]:focus,input[type='submit'][disabled]:hover{background-color:#0069d9;border-color:#0069d9}.button.button-outline,button.button-outline,input[type='button'].button-outline,input[type='reset'].button-outline,input[type='submit'].button-outline{background-color:transparent;color:#0069d9}.button.button-outline:focus,.button.button-outline:hover,button.button-outline:focus,button.button-outline:hover,input[type='button'].button-outline:focus,input[type='button'].button-outline:hover,input[type='reset'].button-outline:focus,input[type='reset'].button-outline:hover,input[type='submit'].button-outline:focus,input[type='submit'].button-outline:hover{background-color:transparent;border-color:#606c76;color:#606c76}.button.button-outline[disabled]:focus,.button.button-outline[disabled]:hover,button.button-outline[disabled]:focus,button.button-outline[disabled]:hover,input[type='button'].button-outline[disabled]:focus,input[type='button'].button-outline[disabled]:hover,input[type='reset'].button-outline[disabled]:focus,input[type='reset'].button-outline[disabled]:hover,input[type='submit'].button-outline[disabled]:focus,input[type='submit'].button-outline[disabled]:hover{border-color:inherit;color:#0069d9}.button.button-clear,button.button-clear,input[type='button'].button-clear,input[type='reset'].button-clear,input[type='submit'].button-clear{background-color:transparent;border-color:transparent;color:#0069d9}.button.button-clear:focus,.button.button-clear:hover,button.button-clear:focus,button.button-clear:hover,input[type='button'].button-clear:focus,input[type='button'].button-clear:hover,input[type='reset'].button-clear:focus,input[type='reset'].button-clear:hover,input[type='submit'].button-clear:focus,input[type='submit'].button-clear:hover{background-color:transparent;border-color:transparent;color:#606c76}.button.button-clear[disabled]:focus,.button.button-clear[disabled]:hover,button.button-clear[disabled]:focus,button.button-clear[disabled]:hover,input[type='button'].button-clear[disabled]:focus,input[type='button'].button-clear[disabled]:hover,input[type='reset'].button-clear[disabled]:focus,input[type='reset'].button-clear[disabled]:hover,input[type='submit'].button-clear[disabled]:focus,input[type='submit'].button-clear[disabled]:hover{color:#0069d9}code{background:#f4f5f6;border-radius:.4rem;font-size:86%;margin:0 .2rem;padding:.2rem .5rem;white-space:nowrap}pre{background:#f4f5f6;border-left:0.3rem solid #0069d9;overflow-y:hidden}pre>code{border-radius:0;display:block;padding:1rem 1.5rem;white-space:pre}hr{border:0;border-top:0.1rem solid #f4f5f6;margin:3.0rem 0}input[type='email'],input[type='number'],input[type='password'],input[type='search'],input[type='tel'],input[type='text'],input[type='url'],textarea,select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:0.1rem solid #d1d1d1;border-radius:.4rem;box-shadow:none;box-sizing:inherit;height:3.8rem;padding:.6rem 1.0rem;width:100%}input[type='email']:focus,input[type='number']:focus,input[type='password']:focus,input[type='search']:focus,input[type='tel']:focus,input[type='text']:focus,input[type='url']:focus,textarea:focus,select:focus{border-color:#0069d9;outline:0}select{background:url('data:image/svg+xml;utf8,') center right no-repeat;padding-right:3.0rem}select:focus{background-image:url('data:image/svg+xml;utf8,')}textarea{min-height:6.5rem}label,legend{display:block;font-size:1.6rem;font-weight:700;margin-bottom:.5rem}fieldset{border-width:0;padding:0}input[type='checkbox'],input[type='radio']{display:inline}.label-inline{display:inline-block;font-weight:normal;margin-left:.5rem}.row{display:flex;flex-direction:column;padding:0;width:100%}.row.row-no-padding{padding:0}.row.row-no-padding>.column{padding:0}.row.row-wrap{flex-wrap:wrap}.row.row-top{align-items:flex-start}.row.row-bottom{align-items:flex-end}.row.row-center{align-items:center}.row.row-stretch{align-items:stretch}.row.row-baseline{align-items:baseline}.row .column{display:block;flex:1 1 auto;margin-left:0;max-width:100%;width:100%}.row .column.column-offset-10{margin-left:10%}.row .column.column-offset-20{margin-left:20%}.row .column.column-offset-25{margin-left:25%}.row .column.column-offset-33,.row .column.column-offset-34{margin-left:33.3333%}.row .column.column-offset-50{margin-left:50%}.row .column.column-offset-66,.row .column.column-offset-67{margin-left:66.6666%}.row .column.column-offset-75{margin-left:75%}.row .column.column-offset-80{margin-left:80%}.row .column.column-offset-90{margin-left:90%}.row .column.column-10{flex:0 0 10%;max-width:10%}.row .column.column-20{flex:0 0 20%;max-width:20%}.row .column.column-25{flex:0 0 25%;max-width:25%}.row .column.column-33,.row .column.column-34{flex:0 0 33.3333%;max-width:33.3333%}.row .column.column-40{flex:0 0 40%;max-width:40%}.row .column.column-50{flex:0 0 50%;max-width:50%}.row .column.column-60{flex:0 0 60%;max-width:60%}.row .column.column-66,.row .column.column-67{flex:0 0 66.6666%;max-width:66.6666%}.row .column.column-75{flex:0 0 75%;max-width:75%}.row .column.column-80{flex:0 0 80%;max-width:80%}.row .column.column-90{flex:0 0 90%;max-width:90%}.row .column .column-top{align-self:flex-start}.row .column .column-bottom{align-self:flex-end}.row .column .column-center{-ms-grid-row-align:center;align-self:center}@media (min-width: 40rem){.row{flex-direction:row;margin-left:-1.0rem;width:calc(100% + 2.0rem)}.row .column{margin-bottom:inherit;padding:0 1.0rem}}a{color:#0069d9;text-decoration:none}a:focus,a:hover{color:#606c76}dl,ol,ul{list-style:none;margin-top:0;padding-left:0}dl dl,dl ol,dl ul,ol dl,ol ol,ol ul,ul dl,ul ol,ul ul{font-size:90%;margin:1.5rem 0 1.5rem 3.0rem}ol{list-style:decimal inside}ul{list-style:circle inside}.button,button,dd,dt,li{margin-bottom:1.0rem}fieldset,input,select,textarea{margin-bottom:1.5rem}blockquote,dl,figure,form,ol,p,pre,table,ul{margin-bottom:2.5rem}table{border-spacing:0;width:100%}td,th{border-bottom:0.1rem solid #e1e1e1;padding:1.2rem 1.5rem;text-align:left}td:first-child,th:first-child{padding-left:0}td:last-child,th:last-child{padding-right:0}b,strong{font-weight:bold}p{margin-top:0}h1,h2,h3,h4,h5,h6{font-weight:300;letter-spacing:-.1rem;margin-bottom:2.0rem;margin-top:0}h1{font-size:4.6rem;line-height:1.2}h2{font-size:3.6rem;line-height:1.25}h3{font-size:2.8rem;line-height:1.3}h4{font-size:2.2rem;letter-spacing:-.08rem;line-height:1.35}h5{font-size:1.8rem;letter-spacing:-.05rem;line-height:1.5}h6{font-size:1.6rem;letter-spacing:0;line-height:1.4}img{max-width:100%}.clearfix:after{clear:both;content:' ';display:table}.float-left{float:left}.float-right{float:right} 10 | 11 | /* General style */ 12 | h1{font-size: 3.6rem; line-height: 1.25} 13 | h2{font-size: 2.8rem; line-height: 1.3} 14 | h3{font-size: 2.2rem; letter-spacing: -.08rem; line-height: 1.35} 15 | h4{font-size: 1.8rem; letter-spacing: -.05rem; line-height: 1.5} 16 | h5{font-size: 1.6rem; letter-spacing: 0; line-height: 1.4} 17 | h6{font-size: 1.4rem; letter-spacing: 0; line-height: 1.2} 18 | pre{padding: 1em;} 19 | 20 | .container{ 21 | margin: 0 auto; 22 | max-width: 80.0rem; 23 | padding: 0 2.0rem; 24 | position: relative; 25 | width: 100% 26 | } 27 | select { 28 | width: auto; 29 | } 30 | 31 | /* Phoenix promo and logo */ 32 | .phx-hero { 33 | text-align: center; 34 | border-bottom: 1px solid #e3e3e3; 35 | background: #eee; 36 | border-radius: 6px; 37 | padding: 3em 3em 1em; 38 | margin-bottom: 3rem; 39 | font-weight: 200; 40 | font-size: 120%; 41 | } 42 | .phx-hero input { 43 | background: #ffffff; 44 | } 45 | .phx-logo { 46 | min-width: 300px; 47 | margin: 1rem; 48 | display: block; 49 | } 50 | .phx-logo img { 51 | width: auto; 52 | display: block; 53 | } 54 | 55 | /* Headers */ 56 | header { 57 | width: 100%; 58 | background: #fdfdfd; 59 | border-bottom: 1px solid #eaeaea; 60 | margin-bottom: 2rem; 61 | } 62 | header section { 63 | align-items: center; 64 | display: flex; 65 | flex-direction: column; 66 | justify-content: space-between; 67 | } 68 | header section :first-child { 69 | order: 2; 70 | } 71 | header section :last-child { 72 | order: 1; 73 | } 74 | header nav ul, 75 | header nav li { 76 | margin: 0; 77 | padding: 0; 78 | display: block; 79 | text-align: right; 80 | white-space: nowrap; 81 | } 82 | header nav ul { 83 | margin: 1rem; 84 | margin-top: 0; 85 | } 86 | header nav a { 87 | display: block; 88 | } 89 | 90 | @media (min-width: 40.0rem) { /* Small devices (landscape phones, 576px and up) */ 91 | header section { 92 | flex-direction: row; 93 | } 94 | header nav ul { 95 | margin: 1rem; 96 | } 97 | .phx-logo { 98 | flex-basis: 527px; 99 | margin: 2rem 1rem; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /assets/js/app.js: -------------------------------------------------------------------------------- 1 | // We need to import the CSS so that webpack will load it. 2 | // The MiniCssExtractPlugin is used to separate it out into 3 | // its own CSS file. 4 | import "../css/app.scss" 5 | 6 | // webpack automatically bundles all modules in your 7 | // entry points. Those entry points can be configured 8 | // in "webpack.config.js". 9 | // 10 | // Import deps with the dep name or local files with a relative path, for example: 11 | // 12 | // import {Socket} from "phoenix" 13 | // import socket from "./socket" 14 | // 15 | import "phoenix_html" 16 | import "alpinejs" 17 | import {Socket} from "phoenix" 18 | import topbar from "topbar" 19 | import {LiveSocket} from "phoenix_live_view" 20 | 21 | let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") 22 | let liveSocket = new LiveSocket('/live', Socket, { 23 | // setup Alpine with LiveView 24 | dom: { 25 | onBeforeElUpdated(from, to) { 26 | if (from.__x) { 27 | window.Alpine.clone(from.__x, to) 28 | } 29 | } 30 | }, 31 | params: { 32 | _csrf_token: csrfToken 33 | }, 34 | // hooks: Hooks 35 | }) 36 | 37 | // Show progress bar on live navigation and form submits 38 | topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"}) 39 | window.addEventListener("phx:page-loading-start", info => topbar.show()) 40 | window.addEventListener("phx:page-loading-stop", info => topbar.hide()) 41 | 42 | // connect if there are any LiveViews on the page 43 | liveSocket.connect() 44 | 45 | // expose liveSocket on window for web console debug logs and latency simulation: 46 | // >> liveSocket.enableDebug() 47 | // >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session 48 | // >> liveSocket.disableLatencySim() 49 | window.liveSocket = liveSocket 50 | 51 | -------------------------------------------------------------------------------- /assets/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "repository": {}, 3 | "description": " ", 4 | "license": "MIT", 5 | "scripts": { 6 | "deploy": "NODE_ENV=production webpack --mode production", 7 | "watch": "webpack --mode development --watch" 8 | }, 9 | "dependencies": { 10 | "alpinejs": "^2.7.3", 11 | "phoenix": "file:../deps/phoenix", 12 | "phoenix_html": "file:../deps/phoenix_html", 13 | "phoenix_live_view": "file:../deps/phoenix_live_view", 14 | "topbar": "^0.1.4" 15 | }, 16 | "devDependencies": { 17 | "@babel/core": "^7.0.0", 18 | "@babel/preset-env": "^7.0.0", 19 | "@tailwindcss/aspect-ratio": "^0.2.0", 20 | "@tailwindcss/forms": "^0.2.1", 21 | "@tailwindcss/typography": "^0.3.1", 22 | "autoprefixer": "^10.0.2", 23 | "babel-loader": "^8.0.0", 24 | "copy-webpack-plugin": "^5.1.1", 25 | "css-loader": "^3.4.2", 26 | "hard-source-webpack-plugin": "^0.13.1", 27 | "mini-css-extract-plugin": "^0.9.0", 28 | "node-sass": "^4.13.1", 29 | "optimize-css-assets-webpack-plugin": "^5.0.1", 30 | "postcss": "^8.1.9", 31 | "postcss-loader": "^4.0.4", 32 | "sass-loader": "^8.0.2", 33 | "tailwindcss": "^2.0.1", 34 | "terser-webpack-plugin": "^2.3.2", 35 | "webpack": "4.41.5", 36 | "webpack-cli": "^3.3.2" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /assets/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | require('tailwindcss'), 4 | require('autoprefixer') 5 | ] 6 | } -------------------------------------------------------------------------------- /assets/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brainlid/pwa-bookit-sample/4ce44aa8999e4b613aacb0a2a1b4fe18005786ac/assets/static/favicon.ico -------------------------------------------------------------------------------- /assets/static/images/phoenix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brainlid/pwa-bookit-sample/4ce44aa8999e4b613aacb0a2a1b4fe18005786ac/assets/static/images/phoenix.png -------------------------------------------------------------------------------- /assets/static/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /assets/tailwind.config.js: -------------------------------------------------------------------------------- 1 | const defaultTheme = require('tailwindcss/defaultTheme') 2 | const colors = require('tailwindcss/colors') 3 | 4 | module.exports = { 5 | purge: [ 6 | "../**/*.html.eex", 7 | "../**/*.html.leex", 8 | "../**/views/**/*.ex", 9 | "../**/live/**/*.ex", 10 | "./js/**/*.js" 11 | ], 12 | darkMode: false, // or 'media' or 'class' 13 | theme: { 14 | extend: { 15 | fontFamily: { 16 | sans: ['Inter var', ...defaultTheme.fontFamily.sans], 17 | }, 18 | }, 19 | colors: { 20 | primary: colors.indigo, 21 | secondary: colors.yellow, 22 | neutral: colors.gray, 23 | blueGray: colors.blueGray, 24 | coolGray: colors.coolGray, 25 | gray: colors.gray, 26 | trueGray: colors.trueGray, 27 | warmGray: colors.warmGray, 28 | red: colors.red, 29 | orange: colors.orange, 30 | amber: colors.amber, 31 | yellow: colors.yellow, 32 | lime: colors.lime, 33 | green: colors.green, 34 | emerald: colors.emerald, 35 | teal: colors.teal, 36 | cyan: colors.cyan, 37 | lightBlue: colors.lightBlue, 38 | blue: colors.blue, 39 | indigo: colors.indigo, 40 | violet: colors.violet, 41 | purple: colors.purple, 42 | fuchsia: colors.fuchsia, 43 | pink: colors.pink, 44 | rose: colors.rose, 45 | white: colors.white, 46 | black: colors.black 47 | }, 48 | }, 49 | variants: {}, 50 | plugins: [ 51 | require('@tailwindcss/forms'), 52 | require('@tailwindcss/typography'), 53 | require('@tailwindcss/aspect-ratio'), 54 | ], 55 | } 56 | -------------------------------------------------------------------------------- /assets/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const glob = require('glob'); 3 | const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); 4 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 5 | const TerserPlugin = require('terser-webpack-plugin'); 6 | const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); 7 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 8 | 9 | module.exports = (env, options) => { 10 | const devMode = options.mode !== 'production'; 11 | 12 | return { 13 | optimization: { 14 | minimizer: [ 15 | new TerserPlugin({ cache: true, parallel: true, sourceMap: devMode }), 16 | new OptimizeCSSAssetsPlugin({}) 17 | ] 18 | }, 19 | entry: { 20 | 'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js']) 21 | }, 22 | output: { 23 | filename: '[name].js', 24 | path: path.resolve(__dirname, '../priv/static/js'), 25 | publicPath: '/js/' 26 | }, 27 | devtool: devMode ? 'eval-cheap-module-source-map' : undefined, 28 | module: { 29 | rules: [ 30 | { 31 | test: /\.js$/, 32 | exclude: /node_modules/, 33 | use: { 34 | loader: 'babel-loader' 35 | } 36 | }, 37 | { 38 | test: /\.[s]?css$/, 39 | use: [ 40 | MiniCssExtractPlugin.loader, 41 | 'css-loader', 42 | 'postcss-loader', 43 | 'sass-loader', 44 | ], 45 | } 46 | ] 47 | }, 48 | plugins: [ 49 | new MiniCssExtractPlugin({ filename: '../css/app.css' }), 50 | new CopyWebpackPlugin([{ from: 'static/', to: '../' }]) 51 | ] 52 | .concat(devMode ? [new HardSourceWebpackPlugin()] : []) 53 | } 54 | }; 55 | -------------------------------------------------------------------------------- /config/config.exs: -------------------------------------------------------------------------------- 1 | # This file is responsible for configuring your application 2 | # and its dependencies with the aid of the Mix.Config module. 3 | # 4 | # This configuration file is loaded before any dependency and 5 | # is restricted to this project. 6 | 7 | # General application configuration 8 | use Mix.Config 9 | 10 | # Configures the endpoint 11 | config :pwa, PwaWeb.Endpoint, 12 | url: [host: "localhost"], 13 | secret_key_base: "JzsuEPR8UT4MRwob8v19wnmV5c9Y60xui9ispyG/wwJHBSBUWPq681nmjIdBgcvc", 14 | render_errors: [view: PwaWeb.ErrorView, accepts: ~w(html json), layout: false], 15 | pubsub_server: Pwa.PubSub, 16 | live_view: [signing_salt: "VSoipTev"] 17 | 18 | # Configures Elixir's Logger 19 | config :logger, :console, 20 | format: "$time $metadata[$level] $message\n", 21 | metadata: [:request_id] 22 | 23 | # Use Jason for JSON parsing in Phoenix 24 | config :phoenix, :json_library, Jason 25 | 26 | # Import environment specific config. This must remain at the bottom 27 | # of this file so it overrides the configuration defined above. 28 | import_config "#{Mix.env()}.exs" 29 | -------------------------------------------------------------------------------- /config/dev.exs: -------------------------------------------------------------------------------- 1 | import Mix.Config 2 | 3 | # For development, we disable any cache and enable 4 | # debugging and code reloading. 5 | # 6 | # The watchers configuration can be used to run external 7 | # watchers to your application. For example, we use it 8 | # with webpack to recompile .js and .css sources. 9 | config :pwa, PwaWeb.Endpoint, 10 | url: [host: "localhost"], 11 | http: [port: 4000], 12 | debug_errors: true, 13 | code_reloader: true, 14 | check_origin: false, 15 | watchers: [ 16 | node: [ 17 | "node_modules/webpack/bin/webpack.js", 18 | "--mode", 19 | "development", 20 | "--watch-stdin", 21 | cd: Path.expand("../assets", __DIR__) 22 | ] 23 | ] 24 | 25 | # ## SSL Support 26 | # 27 | # In order to use HTTPS in development, a self-signed 28 | # certificate can be generated by running the following 29 | # Mix task: 30 | # 31 | # mix phx.gen.cert 32 | # 33 | # Note that this task requires Erlang/OTP 20 or later. 34 | # Run `mix help phx.gen.cert` for more information. 35 | # 36 | # The `http:` config above can be replaced with: 37 | # 38 | # https: [ 39 | # port: 4001, 40 | # cipher_suite: :strong, 41 | # keyfile: "priv/cert/selfsigned_key.pem", 42 | # certfile: "priv/cert/selfsigned.pem" 43 | # ], 44 | # 45 | # If desired, both `http:` and `https:` keys can be 46 | # configured to run both http and https servers on 47 | # different ports. 48 | 49 | # Watch static and templates for browser reloading. 50 | config :pwa, PwaWeb.Endpoint, 51 | live_reload: [ 52 | patterns: [ 53 | ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", 54 | ~r"priv/gettext/.*(po)$", 55 | ~r"lib/pwa_web/(live|views)/.*(ex)$", 56 | ~r"lib/pwa_web/templates/.*(eex)$" 57 | ] 58 | ] 59 | 60 | # Do not include metadata nor timestamps in development logs 61 | config :logger, :console, format: "[$level] $message\n" 62 | 63 | # Set a higher stacktrace during development. Avoid configuring such 64 | # in production as building large stacktraces may be expensive. 65 | config :phoenix, :stacktrace_depth, 20 66 | 67 | # Initialize plugs at runtime for faster development compilation 68 | config :phoenix, :plug_init_mode, :runtime 69 | -------------------------------------------------------------------------------- /config/prod.exs: -------------------------------------------------------------------------------- 1 | import Mix.Config 2 | 3 | # For production, don't forget to configure the url host 4 | # to something meaningful, Phoenix uses this information 5 | # when generating URLs. 6 | # 7 | # Note we also include the path to a cache manifest 8 | # containing the digested version of static files. This 9 | # manifest is generated by the `mix phx.digest` task, 10 | # which you should run after static files are built and 11 | # before starting your production server. 12 | config :pwa, PwaWeb.Endpoint, 13 | cache_static_manifest: "priv/static/cache_manifest.json", 14 | server: true 15 | 16 | # Do not print debug messages in production 17 | config :logger, level: :info 18 | -------------------------------------------------------------------------------- /config/prod.secret.exs: -------------------------------------------------------------------------------- 1 | # In this file, we load production configuration and secrets 2 | # from environment variables. You can also hardcode secrets, 3 | # although such is generally not recommended and you have to 4 | # remember to add this file to your .gitignore. 5 | use Mix.Config 6 | 7 | secret_key_base = 8 | System.get_env("SECRET_KEY_BASE") || 9 | raise """ 10 | environment variable SECRET_KEY_BASE is missing. 11 | You can generate one by calling: mix phx.gen.secret 12 | """ 13 | 14 | config :pwa, PwaWeb.Endpoint, 15 | http: [ 16 | port: String.to_integer(System.get_env("PORT") || "4000"), 17 | transport_options: [socket_opts: [:inet6]] 18 | ], 19 | secret_key_base: secret_key_base 20 | 21 | # ## Using releases (Elixir v1.9+) 22 | # 23 | # If you are doing OTP releases, you need to instruct Phoenix 24 | # to start each relevant endpoint: 25 | # 26 | # config :pwa, PwaWeb.Endpoint, server: true 27 | # 28 | # Then you can assemble a release by calling `mix release`. 29 | # See `mix help release` for more information. 30 | -------------------------------------------------------------------------------- /config/runtime.exs: -------------------------------------------------------------------------------- 1 | import Config 2 | 3 | if config_env() == :prod do 4 | secret_key_base = 5 | System.get_env("SECRET_KEY_BASE") || 6 | raise """ 7 | environment variable SECRET_KEY_BASE is missing. 8 | You can generate one by calling: mix phx.gen.secret 9 | """ 10 | 11 | app_domain = System.fetch_env!("APP_DOMAIN") 12 | 13 | config :phoenix_example, PhoenixExampleWeb.Endpoint, 14 | url: [host: app_domain, port: 443], 15 | http: [ 16 | port: String.to_integer(System.get_env("PORT") || "8080"), 17 | transport_options: [socket_opts: [:inet6]] 18 | ], 19 | secret_key_base: secret_key_base 20 | end 21 | -------------------------------------------------------------------------------- /config/test.exs: -------------------------------------------------------------------------------- 1 | import Mix.Config 2 | 3 | # We don't run a server during test. If one is required, 4 | # you can enable the server option below. 5 | config :pwa, PwaWeb.Endpoint, 6 | http: [port: 4002], 7 | server: false 8 | 9 | # Print only warnings and errors during test 10 | config :logger, level: :warn 11 | -------------------------------------------------------------------------------- /lib/pwa.ex: -------------------------------------------------------------------------------- 1 | defmodule Pwa do 2 | @moduledoc """ 3 | Pwa keeps the contexts that define your domain 4 | and business logic. 5 | 6 | Contexts are also responsible for managing your data, regardless 7 | if it comes from the database, an external API or others. 8 | """ 9 | end 10 | -------------------------------------------------------------------------------- /lib/pwa/application.ex: -------------------------------------------------------------------------------- 1 | defmodule Pwa.Application do 2 | # See https://hexdocs.pm/elixir/Application.html 3 | # for more information on OTP Applications 4 | @moduledoc false 5 | 6 | use Application 7 | 8 | def start(_type, _args) do 9 | children = [ 10 | # Start the Telemetry supervisor 11 | PwaWeb.Telemetry, 12 | # Start the PubSub system 13 | {Phoenix.PubSub, name: Pwa.PubSub}, 14 | # Start the Endpoint (http/https) 15 | PwaWeb.Endpoint 16 | # Start a worker by calling: Pwa.Worker.start_link(arg) 17 | # {Pwa.Worker, arg} 18 | ] 19 | 20 | # See https://hexdocs.pm/elixir/Supervisor.html 21 | # for other strategies and supported options 22 | opts = [strategy: :one_for_one, name: Pwa.Supervisor] 23 | Supervisor.start_link(children, opts) 24 | end 25 | 26 | # Tell Phoenix to update the endpoint configuration 27 | # whenever the application is updated. 28 | def config_change(changed, _new, removed) do 29 | PwaWeb.Endpoint.config_change(changed, removed) 30 | :ok 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/pwa/books.ex: -------------------------------------------------------------------------------- 1 | defmodule Pwa.Books do 2 | @moduledoc """ 3 | The Books context. 4 | """ 5 | 6 | import Ecto.Query, warn: false 7 | alias Pwa.FakeRepo, as: Repo 8 | 9 | alias Pwa.Books.Book 10 | 11 | @doc """ 12 | Returns the list of books. 13 | 14 | ## Examples 15 | 16 | iex> list_books() 17 | [%Book{}, ...] 18 | 19 | """ 20 | def list_books do 21 | Repo.all(Book) 22 | end 23 | 24 | @doc """ 25 | Gets a single book. 26 | 27 | Raises `Ecto.NoResultsError` if the Book does not exist. 28 | 29 | ## Examples 30 | 31 | iex> get_book!(123) 32 | %Book{} 33 | 34 | iex> get_book!(456) 35 | ** (Ecto.NoResultsError) 36 | 37 | """ 38 | def get_book!(id), do: Repo.get!(Book, id) 39 | 40 | @doc """ 41 | Creates a book. 42 | 43 | ## Examples 44 | 45 | iex> create_book(%{field: value}) 46 | {:ok, %Book{}} 47 | 48 | iex> create_book(%{field: bad_value}) 49 | {:error, %Ecto.Changeset{}} 50 | 51 | """ 52 | def create_book(attrs \\ %{}) do 53 | %Book{} 54 | |> Book.changeset(attrs) 55 | |> Repo.insert() 56 | end 57 | 58 | @doc """ 59 | Updates a book. 60 | 61 | ## Examples 62 | 63 | iex> update_book(book, %{field: new_value}) 64 | {:ok, %Book{}} 65 | 66 | iex> update_book(book, %{field: bad_value}) 67 | {:error, %Ecto.Changeset{}} 68 | 69 | """ 70 | def update_book(%Book{} = book, attrs) do 71 | book 72 | |> Book.changeset(attrs) 73 | |> Repo.update() 74 | end 75 | 76 | @doc """ 77 | Deletes a book. 78 | 79 | ## Examples 80 | 81 | iex> delete_book(book) 82 | {:ok, %Book{}} 83 | 84 | iex> delete_book(book) 85 | {:error, %Ecto.Changeset{}} 86 | 87 | """ 88 | def delete_book(%Book{} = book) do 89 | Repo.delete(book) 90 | end 91 | 92 | @doc """ 93 | Returns an `%Ecto.Changeset{}` for tracking book changes. 94 | 95 | ## Examples 96 | 97 | iex> change_book(book) 98 | %Ecto.Changeset{data: %Book{}} 99 | 100 | """ 101 | def change_book(%Book{} = book, attrs \\ %{}) do 102 | Book.changeset(book, attrs) 103 | end 104 | end 105 | -------------------------------------------------------------------------------- /lib/pwa/books/book.ex: -------------------------------------------------------------------------------- 1 | defmodule Pwa.Books.Book do 2 | use Ecto.Schema 3 | import Ecto.Changeset 4 | 5 | schema "books" do 6 | field :author, :string, required: true 7 | field :title, :string, required: true 8 | 9 | timestamps() 10 | end 11 | 12 | @required [:title, :author] 13 | 14 | @doc false 15 | def changeset(book, attrs) do 16 | book 17 | |> cast(attrs, [:title, :author]) 18 | |> validate_required(@required) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/pwa/fake_repo.ex: -------------------------------------------------------------------------------- 1 | defmodule Pwa.FakeRepo do 2 | alias Pwa.Books.Book 3 | alias Ecto.Changeset 4 | 5 | def all(Book) do 6 | [ 7 | %Book{id: "1", title: "Alice in Wonderland", author: "Lewis Carroll"}, 8 | %Book{id: "2", title: "Peter Pan", author: "J. M. Barrie"}, 9 | %Book{id: "3", title: "Cat in the Hat", author: "Dr. Seuss"}, 10 | %Book{id: "4", title: "Don Quixote", author: "Miguel De Cervantes"}, 11 | %Book{id: "5", title: "Pilgrim's Progress", author: "John Bunyan"}, 12 | %Book{id: "6", title: "Robinson Crusoe", author: "Daniel Defoe"}, 13 | %Book{id: "7", title: "Gulliver's Travels", author: "Jonathan Swift"}, 14 | %Book{id: "8", title: "Tom Jones", author: "Henry Fielding"}, 15 | %Book{id: "9", title: "Clarissa", author: "Samuel Richardson"}, 16 | %Book{id: "10", title: "Tristram Shandy", author: "Laurence Sterne"}, 17 | %Book{id: "11", title: "Emma", author: "Jane Austen"}, 18 | %Book{id: "12", title: "Frankenstein", author: "Mary Shelley"}, 19 | %Book{id: "13", title: "Wuthering Heights", author: "Emily Brontë"}, 20 | %Book{id: "14", title: "Little Women", author: "Louisa M. Alcott"} 21 | ] 22 | end 23 | 24 | def get!(Book, id) do 25 | Book 26 | |> all() 27 | |> Enum.find(&(&1.id == id)) 28 | |> case do 29 | nil -> 30 | raise ArgumentError, "Book not found" 31 | 32 | %Book{} = book -> 33 | book 34 | end 35 | end 36 | 37 | def insert(%Changeset{} = changeset) do 38 | Changeset.apply_action(changeset, :insert) 39 | end 40 | 41 | def update(%Changeset{} = changeset) do 42 | Changeset.apply_action(changeset, :update) 43 | end 44 | 45 | def delete(%Book{} = book) do 46 | {:ok, book} 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/pwa_web.ex: -------------------------------------------------------------------------------- 1 | defmodule PwaWeb do 2 | @moduledoc """ 3 | The entrypoint for defining your web interface, such 4 | as controllers, views, channels and so on. 5 | 6 | This can be used in your application as: 7 | 8 | use PwaWeb, :controller 9 | use PwaWeb, :view 10 | 11 | The definitions below will be executed for every view, 12 | controller, etc, so keep them short and clean, focused 13 | on imports, uses and aliases. 14 | 15 | Do NOT define functions inside the quoted expressions 16 | below. Instead, define any helper function in modules 17 | and import those modules here. 18 | """ 19 | 20 | def controller do 21 | quote do 22 | use Phoenix.Controller, namespace: PwaWeb 23 | 24 | import Plug.Conn 25 | import PwaWeb.Gettext 26 | alias PwaWeb.Router.Helpers, as: Routes 27 | end 28 | end 29 | 30 | def view do 31 | quote do 32 | use Phoenix.View, 33 | root: "lib/pwa_web/templates", 34 | namespace: PwaWeb 35 | 36 | # Import convenience functions from controllers 37 | import Phoenix.Controller, 38 | only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1] 39 | 40 | # Include shared imports and aliases for views 41 | unquote(view_helpers()) 42 | end 43 | end 44 | 45 | def live_view do 46 | quote do 47 | use Phoenix.LiveView, 48 | layout: {PwaWeb.LayoutView, "live.html"} 49 | import PwaWeb.Components 50 | 51 | unquote(view_helpers()) 52 | end 53 | end 54 | 55 | def live_component do 56 | quote do 57 | use Phoenix.LiveComponent 58 | import PwaWeb.Components 59 | 60 | unquote(view_helpers()) 61 | end 62 | end 63 | 64 | def router do 65 | quote do 66 | use Phoenix.Router 67 | 68 | import Plug.Conn 69 | import Phoenix.Controller 70 | import Phoenix.LiveView.Router 71 | end 72 | end 73 | 74 | def channel do 75 | quote do 76 | use Phoenix.Channel 77 | import PwaWeb.Gettext 78 | end 79 | end 80 | 81 | defp view_helpers do 82 | quote do 83 | # Use all HTML functionality (forms, tags, etc) 84 | use Phoenix.HTML 85 | 86 | # Import LiveView helpers (live_render, live_component, live_patch, etc) 87 | import Phoenix.LiveView.Helpers 88 | import PwaWeb.LiveHelpers 89 | 90 | # Import basic rendering functionality (render, render_layout, etc) 91 | import Phoenix.View 92 | 93 | import PwaWeb.ErrorHelpers 94 | import PwaWeb.Gettext 95 | alias PwaWeb.Router.Helpers, as: Routes 96 | end 97 | end 98 | 99 | @doc """ 100 | When used, dispatch to the appropriate controller/view/etc. 101 | """ 102 | defmacro __using__(which) when is_atom(which) do 103 | apply(__MODULE__, which, []) 104 | end 105 | end 106 | -------------------------------------------------------------------------------- /lib/pwa_web/channels/user_socket.ex: -------------------------------------------------------------------------------- 1 | defmodule PwaWeb.UserSocket do 2 | use Phoenix.Socket 3 | 4 | ## Channels 5 | # channel "room:*", PwaWeb.RoomChannel 6 | 7 | # Socket params are passed from the client and can 8 | # be used to verify and authenticate a user. After 9 | # verification, you can put default assigns into 10 | # the socket that will be set for all channels, ie 11 | # 12 | # {:ok, assign(socket, :user_id, verified_user_id)} 13 | # 14 | # To deny connection, return `:error`. 15 | # 16 | # See `Phoenix.Token` documentation for examples in 17 | # performing token verification on connect. 18 | @impl true 19 | def connect(_params, socket, _connect_info) do 20 | {:ok, socket} 21 | end 22 | 23 | # Socket id's are topics that allow you to identify all sockets for a given user: 24 | # 25 | # def id(socket), do: "user_socket:#{socket.assigns.user_id}" 26 | # 27 | # Would allow you to broadcast a "disconnect" event and terminate 28 | # all active sockets and channels for a given user: 29 | # 30 | # PwaWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) 31 | # 32 | # Returning `nil` makes this socket anonymous. 33 | @impl true 34 | def id(_socket), do: nil 35 | end 36 | -------------------------------------------------------------------------------- /lib/pwa_web/components.ex: -------------------------------------------------------------------------------- 1 | defmodule PwaWeb.Components do 2 | @moduledoc """ 3 | Defines a set of web components for use in LiveView templates. 4 | """ 5 | import Phoenix.LiveView.Helpers 6 | 7 | @doc """ 8 | Render the "X" corner close button for a modal. 9 | 10 | Composable portion of a modal. 11 | """ 12 | defdelegate modal_times_close(), to: PwaWeb.Components.Modal, as: :modal_times_close 13 | 14 | @doc """ 15 | Render the markup for displaying a modal title. 16 | """ 17 | defdelegate modal_title(title_text), to: PwaWeb.Components.Modal 18 | 19 | @doc """ 20 | Render the markup for displaying a modal's instruction text. 21 | """ 22 | defdelegate modal_instructions_text(text), to: PwaWeb.Components.Modal 23 | 24 | @doc """ 25 | Renders a component inside the `PwaWeb.Components.Modal` component. 26 | 27 | This modal needs to be routed to, rather than toggled on/off as we have 28 | normally done in the past. 29 | 30 | The rendered modal receives a `:return_to` option to properly update the URL 31 | when the modal is closed. 32 | 33 | All other options are passed directly into the rendered component. 34 | 35 | ## Examples 36 | 37 | <%= modal @socket, SomeComponent, 38 | id: @product.id || :new, 39 | action: @live_action, 40 | product: @product, 41 | return_to: Routes.some_path(@socket, :index) %> 42 | 43 | In this example, `product` is being passed into `SomeComponent`. 44 | 45 | ## Configuration 46 | 47 | The following options can be passed: 48 | 49 | - `:title`: sets the title of the modal 50 | - `:return_to`: used to redirect when the modal is closed 51 | 52 | """ 53 | def modal(socket, component, opts) do 54 | path = Keyword.fetch!(opts, :return_to) 55 | title = Keyword.get(opts, :title, nil) 56 | 57 | modal_opts = [ 58 | id: :modal, 59 | return_to: path, 60 | component: component, 61 | title: title, 62 | opts: opts 63 | ] 64 | 65 | live_component(socket, PwaWeb.Components.Modal, modal_opts) 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /lib/pwa_web/components/modal.ex: -------------------------------------------------------------------------------- 1 | defmodule PwaWeb.Components.Modal do 2 | @moduledoc """ 3 | Modal component that uses route state to toggle it open or closed. 4 | 5 | Heavily inspired by phoenix live generators. 6 | """ 7 | use PwaWeb, :live_component 8 | 9 | @impl true 10 | def render(assigns) do 11 | ~L""" 12 |
63 | <%= text %> 64 |
65 | """ 66 | end 67 | 68 | def modal_button_tray_close(opts \\ []) do 69 | close_text = Keyword.get(opts, :close_text, "Close") 70 | color = Keyword.get(opts, :color, "white") 71 | 72 | color_classes = 73 | case color do 74 | "white" -> 75 | "border-gray-300 bg-white text-gray-700 hover:text-gray-500 focus:ring-blue-500" 76 | 77 | other -> 78 | "border-transparent bg-#{other}-600 text-white hover:bg-#{other}-700 focus:outline-none" 79 | end 80 | 81 | ~E""" 82 |<%= error_tag f, :title %>
25 |<%= error_tag f, :author %>
33 |<%= live_redirect book.title, to: Routes.book_show_path(@socket, :show, book) %>
30 |31 | <%= book.author %> 32 |
33 |16 | Book details. 17 |
18 |Peace of mind from prototype to production
5 | 6 | 15 |<%= get_flash(@conn, :info) %>
3 |<%= get_flash(@conn, :error) %>
4 | <%= @inner_content %> 5 |<%= live_flash(@flash, :info) %>
5 | 6 |<%= live_flash(@flash, :error) %>
9 | 10 | <%= @inner_content %> 11 |