Skip to content

Commit

Permalink
feat: add native popovers for seen icons
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Sep 19, 2024
1 parent 6f35311 commit 1764a2c
Show file tree
Hide file tree
Showing 16 changed files with 361 additions and 34 deletions.
5 changes: 0 additions & 5 deletions .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
send_interrupt = false
stop_on_error = false

[proxy]
enabled = true
proxy_port = 8081
app_port = 8080

[log]
main_only = false
time = false
Expand Down
20 changes: 20 additions & 0 deletions components/popover.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package components

css anchor(name string) {
anchor-name: { name };
}

css anchorPosition(name string) {
position-anchor: { name };
inset-area: top;
position-try-fallbacks: flip-block;
}

templ Popover(anchorName string, content string) {
<button popovertarget={ anchorName } class={ anchor(anchorName),"focus-visible:outline-dashed focus-visible:outline-offset-2 focus-visible:outline-neutral-400 dark:focus-visible:outline-neutral-600 rounded-full" }>
{ children... }
</button>
<div id={ anchorName } popover class={ "text-xs shadow-md text-neutral-700 bg-neutral-200 dark:text-neutral-300 dark:bg-neutral-800 p-2 rounded", anchorPosition(anchorName) }>
{ content }
</div>
}
149 changes: 149 additions & 0 deletions components/popover_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,10 @@ video {
stroke: #a3a3a3;
}

.p-2 {
padding: 0.5rem;
}

.px-2 {
padding-left: 0.5rem;
padding-right: 0.5rem;
Expand Down Expand Up @@ -1186,6 +1190,30 @@ video {
}
}

@supports (anchor-name: --myanchor) {
[popover] {
margin: 0.25rem;
display: none;
border-style: none;
opacity: 0;
transition:
opacity 500ms,
display 500ms allow-discrete,
overlay 500ms allow-discrete;
&:popover-open {
display: block;
}
&:popover-open {
opacity: 1;
}
&:popover-open {
@starting-style {
opacity: 0;
}
}
}
}

.placeholder\:text-neutral-400::-moz-placeholder {
--tw-text-opacity: 1;
color: rgb(163 163 163 / var(--tw-text-opacity));
Expand Down Expand Up @@ -1416,6 +1444,11 @@ video {
background-color: rgb(64 64 64 / var(--tw-bg-opacity));
}

.dark\:bg-neutral-800 {
--tw-bg-opacity: 1;
background-color: rgb(38 38 38 / var(--tw-bg-opacity));
}

.dark\:bg-neutral-900 {
--tw-bg-opacity: 1;
background-color: rgb(23 23 23 / var(--tw-bg-opacity));
Expand Down
33 changes: 33 additions & 0 deletions public/styles.5709e2.css → public/styles.e77e16.css
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ video {
stroke: #a3a3a3;
}

.p-2 {
padding: 0.5rem;
}

.px-2 {
padding-left: 0.5rem;
padding-right: 0.5rem;
Expand Down Expand Up @@ -1176,6 +1180,30 @@ video {
}
}

@supports (anchor-name: --myanchor) {
[popover] {
margin: 0.25rem;
display: none;
border-style: none;
opacity: 0;
transition:
opacity 500ms,
display 500ms allow-discrete,
overlay 500ms allow-discrete;
&:popover-open {
display: block;
}
&:popover-open {
opacity: 1;
}
&:popover-open {
@starting-style {
opacity: 0;
}
}
}
}

.placeholder\:text-neutral-400::-moz-placeholder {
--tw-text-opacity: 1;
color: rgb(163 163 163 / var(--tw-text-opacity));
Expand Down Expand Up @@ -1406,6 +1434,11 @@ video {
background-color: rgb(64 64 64 / var(--tw-bg-opacity));
}

.dark\:bg-neutral-800 {
--tw-bg-opacity: 1;
background-color: rgb(38 38 38 / var(--tw-bg-opacity));
}

.dark\:bg-neutral-900 {
--tw-bg-opacity: 1;
background-color: rgb(23 23 23 / var(--tw-bg-opacity));
Expand Down
19 changes: 19 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,22 @@
}
}
}

@supports (anchor-name: --myanchor) {
[popover] {
@apply m-1 border-none hidden opacity-0;

transition:
opacity 500ms,
display 500ms allow-discrete,
overlay 500ms allow-discrete;

&:popover-open {
@apply block opacity-100;

@starting-style {
opacity: 0;
}
}
}
}
5 changes: 4 additions & 1 deletion views/genre.templ
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ templ Genre(props GenreProps) {
<span class="tabular-nums whitespace-nowrap">
{ movie.ReleaseDate.Format("2006-01-02") }
</span>
@Seen(movie.Seen)
@Seen(SeenProps{
Seen: movie.Seen,
ID: movie.ID,
})
</span>
</li>
}
Expand Down
5 changes: 4 additions & 1 deletion views/genre_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion views/layout.templ
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ templ Layout(props LayoutProps) {
<meta name="twitter:site" content="@rnattochdag"/>
<meta name="twitter:creator" content="@rnattochdag"/>
<link rel="icon" type="image/png" href="/public/favicon.png"/>
<link href="/public/styles.5709e2.css" rel="stylesheet"/>
<link href="/public/styles.e77e16.css" rel="stylesheet"/>
<link rel="manifest" href="/public/manifest.webmanifest"/>
<script src="/public/htmx.2.0.2.min.js"></script>
<script src="/public/htmx.head-support.20240912.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion views/layout_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion views/moviesByYear.templ
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ templ MoviesByYear(year string, movies types.Movies) {
<span class="tabular-nums whitespace-nowrap">
{ movie.ReleaseDate.Format("2006-01-02") }
</span>
@Seen(movie.Seen)
@Seen(SeenProps{
Seen: movie.Seen,
ID: movie.ID,
})
</span>
</li>
}
Expand Down
5 changes: 4 additions & 1 deletion views/moviesByYear_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion views/person.templ
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ templ Credit(title string, data types.PersonMovies, id string) {
>
{ movie.ReleaseDate.Format("2006") }
</a>
@Seen(movie.Seen)
@Seen(SeenProps{
Title: title,
Seen: movie.Seen,
ID: movie.ID,
})
</span>
</li>
}
Expand Down
Loading

0 comments on commit 1764a2c

Please sign in to comment.