Music streaming on ATProto!

feat: add font, replace hologram blog test with very basic text

ovyerus.com 704ecff8 f10bc0f5

verified
Changed files
+74 -103
assets
css
js
config
lib
comet_app
comet_web
components
layouts
+5
assets/css/app.css
···
[data-phx-session], [data-phx-teleported-src] { display: contents }
/* This file is for your main application CSS */
+
@theme {
+
--color-brand-light: #ffa34e;
+
--color-brand-dark: #ff4400;
+
--font-sans: "Work Sans Variable", ui-sans-serif, system-ui, sans-serif;
+
}
+1
assets/js/app.js
···
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
import "phoenix_html"
+
import "@fontsource-variable/work-sans"
// Establish Phoenix Socket and LiveView configuration.
import {Socket} from "phoenix"
import {LiveSocket} from "phoenix_live_view"
+6 -2
config/config.exs
···
version: "0.25.4",
comet: [
args:
-
~w(js/app.js --bundle --target=es2022 --outdir=../priv/static/assets/js --external:/fonts/* --external:/images/* --alias:@=.),
+
~w(js/app.js --bundle --target=es2022 --outdir=../priv/static/assets/js --external:/fonts/* --external:/images/* --loader:.woff2=file --alias:@=.),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => [Path.expand("../deps", __DIR__), Mix.Project.build_path()]}
]
···
cd: Path.expand("..", __DIR__)
],
version_check: false,
-
path: System.get_env("TAILWINDCSS_PATH", Path.expand("../assets/node_modules/.bin/tailwindcss", __DIR__))
+
path:
+
System.get_env(
+
"TAILWINDCSS_PATH",
+
Path.expand("../assets/node_modules/.bin/tailwindcss", __DIR__)
+
)
# Configure Elixir's Logger
config :logger, :default_formatter,
-16
lib/comet_app/components/post_preview.ex
···
-
defmodule CometApp.Components.PostPreview do
-
use Hologram.Component
-
alias Hologram.UI.Link
-
-
prop :post, :map
-
-
def template do
-
~HOLO"""
-
<article class="post-preview">
-
<h2>{@post.title}</h2>
-
<p>{@post.excerpt}</p>
-
<Link to={CometApp.PostPage, id: @post.id}>Read more</Link>
-
</article>
-
"""
-
end
-
end
+11
lib/comet_app/components/title.ex
···
+
defmodule CometApp.Components.Title do
+
use Hologram.Component
+
+
prop :text, :string, default: nil
+
+
def template do
+
~HOLO"""
+
<title>{if @text do "#{@text} - Comet" else "Comet" end}</title>
+
"""
+
end
+
end
+22 -1
lib/comet_app/layouts/main.ex
···
defmodule CometApp.MainLayout do
use Hologram.Component
-
alias Hologram.UI.Link
+
alias CometApp.Components.Title
alias Hologram.UI.Runtime
+
+
prop :page_title, :string, default: nil
+
+
def template do
+
~HOLO"""
+
<!DOCTYPE html>
+
<html lang="en">
+
<head>
+
<meta charset="utf-8" />
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
+
<link rel="stylesheet" href="/assets/js/app.css" />
+
<link rel="stylesheet" href="/assets/css/app.css" />
+
<Title text={@page_title} />
+
<Runtime />
+
</head>
+
<body class="from-amber-900 bg-linear-to-tl to-stone-950 to-80% bg-fixed text-white p-10 w-screen h-screen flex justify-center flex-col">
+
<slot/>
+
</body>
+
</html>
+
"""
+
end
end
-18
lib/comet_app/layouts/main.holo
···
-
<!DOCTYPE html>
-
<html lang="en">
-
<head>
-
<meta charset="utf-8" />
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
-
<title>Comet App</title>
-
<link phx-track-static rel="stylesheet" href="/assets/css/app.css" />
-
<Runtime />
-
</head>
-
<body>
-
<nav class="bg-red-500 text-2xl">
-
<Link to={CometApp.HomePage}>Home</Link>
-
</nav>
-
<main>
-
<slot />
-
</main>
-
</body>
-
</html>
+15 -17
lib/comet_app/pages/home.ex
···
defmodule CometApp.HomePage do
use Hologram.Page
-
alias CometApp.Components.PostPreview
route "/"
-
layout CometApp.MainLayout
+
layout CometApp.MainLayout, page_title: "Home"
-
def init(_params, component, _server) do
-
# In real app, fetch from database
-
posts = [
-
%{id: 1, title: "First Post", excerpt: "This is my first post"},
-
%{id: 2, title: "Second Post", excerpt: nil}
-
]
+
# def init(_params, component, _server) do
+
# # In real app, fetch from database
+
# posts = [
+
# %{id: 1, title: "First Post", excerpt: "This is my first post"},
+
# %{id: 2, title: "Second Post", excerpt: nil}
+
# ]
-
put_state(component, :posts, posts)
-
end
+
# put_state(component, :posts, posts)
+
# end
def template do
~HOLO"""
-
<h1>Welcome to my Blog</h1>
-
-
<div class="posts">
-
{%for post <- @posts}
-
<PostPreview post={post} />
-
{/for}
-
</div>
+
<h1 class="italic text-9xl tracking-tighter leading-30 mb-10 font-thin">
+
<span class="font-medium">Comet</span> is the next-generation of music streaming.
+
</h1>
+
<p class="text-2xl font-light">
+
Powered by the AT Protocol, we're putting the power back in the hands of musicians.
+
</p>
"""
end
end
-48
lib/comet_app/pages/post_view.ex
···
-
defmodule CometApp.PostPage do
-
use Hologram.Page
-
-
route "/posts/:id"
-
-
param :id, :integer
-
-
layout CometApp.MainLayout
-
-
def init(params, component, _server) do
-
# In real app, fetch from database
-
post = %{
-
id: params.id,
-
title: "Example Post",
-
content: "This is the full content...",
-
likes: 0
-
}
-
-
put_state(component, :post, post)
-
end
-
-
def template do
-
~HOLO"""
-
<article>
-
<h1>{@post.title}</h1>
-
<p>{@post.content}</p>
-
-
<div class="likes">
-
Likes: {@post.likes}
-
<button $click="like_post">Like</button>
-
</div>
-
</article>
-
"""
-
end
-
-
def action(:like_post, _params, component) do
-
# Update likes locally first for instant feedback
-
component
-
|> put_state([:post, :likes], component.state.post.likes + 1)
-
|> put_command(:save_like, post_id: component.state.post.id)
-
end
-
-
def command(:save_like, params, server) do
-
# In real app, save to database
-
IO.puts("Liked post #{params.post_id}")
-
server
-
end
-
end
+1
lib/comet_web/components/layouts/root.html.heex
···
<.live_title default="Comet" suffix=" · Phoenix Framework">
{assigns[:page_title]}
</.live_title>
+
<link phx-track-static rel="stylesheet" href={~p"/assets/js/app.css"} />
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
<script defer phx-track-static type="text/javascript" src={~p"/assets/js/app.js"}>
</script>
+4 -1
package.json
···
"format": "prettier --write ."
},
"type": "commonjs",
-
"workspaces": []
+
"workspaces": [],
+
"dependencies": {
+
"@fontsource-variable/work-sans": "^5.2.8"
+
}
}
+9
pnpm-lock.yaml
···
importers:
.:
+
dependencies:
+
'@fontsource-variable/work-sans':
+
specifier: ^5.2.8
+
version: 5.2.8
devDependencies:
'@tailwindcss/cli':
specifier: ^4.1.17
···
version: 5.9.3
packages:
+
+
'@fontsource-variable/work-sans@5.2.8':
+
resolution: {integrity: sha512-8uWtTt0/B5NxGie9xUVD5y5Ch4Q+Hy7kFYKtUpwYbzSAgJEoaMxT8rMnfnK7zfAYSLC8GnGO1/tXrFtKIYYQVQ==}
'@jridgewell/gen-mapping@0.3.13':
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
···
hasBin: true
snapshots:
+
+
'@fontsource-variable/work-sans@5.2.8': {}
'@jridgewell/gen-mapping@0.3.13':
dependencies: