Skip to content

Commit d60bedc

Browse files
committed
fix: themes, improve app components
1 parent ab41a17 commit d60bedc

File tree

10 files changed

+60
-99
lines changed

10 files changed

+60
-99
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@e280/kv": "^0.1.0",
1919
"@e280/renraku": "^0.5.0",
2020
"@e280/science": "^0.1.2",
21-
"@e280/sly": "^0.2.0-28",
21+
"@e280/sly": "^0.2.0-31",
2222
"@e280/strata": "^0.2.0",
2323
"@e280/stz": "^0.2.10",
2424
"@noble/ed25519": "^3.0.0",

s/app/index.html.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ export default ssg.page(import.meta.url, async orb => ({
2121
url: `https://${domain}/app/`,
2222
},
2323

24-
head: html`
25-
<link rel="stylesheet" href="${orb.url("/themes/basic.css")}"/>
26-
`,
24+
head: html``,
2725

2826
body: html`
29-
<h1>Example app using Authlocal</h1>
27+
<h1>Example app using Authlocal <small>${orb.packageVersion()}</small></h1>
3028
<p>This page is a test for a typical federated auth integration with <a href="/">Authlocal</a></p>
3129
<auth-button src="/"></auth-button>
3230
<auth-user></auth-user>

s/app/lib/parts/install.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {dom} from "@e280/sly"
33
import {Auth} from "./auth.js"
44
import {AuthOptions} from "./types.js"
55
import {prepareViews} from "../ui/views.js"
6-
import {commonElements} from "../../../common/ui/views/views.js"
6+
import {commonElements, commonViews} from "../../../common/ui/views/views.js"
77

88
export type AuthlocalInstallation = Awaited<ReturnType<typeof install>>
99

@@ -18,6 +18,6 @@ export async function install(options: AuthOptions) {
1818
...elements,
1919
})
2020

21-
return {auth, views}
21+
return {auth, views: {...commonViews, ...views}}
2222
}
2323

s/app/lib/themes/basic.css.ts

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,45 @@ export const basic = css`
88
${cssReset}
99
1010
@layer overlay {
11-
[part="button"] {
12-
all: unset;
13-
font: inherit;
14-
color: inherit;
15-
16-
cursor: pointer;
17-
padding: 1em 0.5em;
18-
border-radius: 0.5em;
19-
border: 0.1em solid transparent;
20-
21-
font-weight: bold;
22-
color: #fff;
23-
background: #567;
24-
text-shadow: 0.1em 0.1em 0.1em #0008;
25-
box-shadow: 0.1em 0.1em 0.3em #0004;
11+
:host([view="auth-button"]) {
12+
[part~="button"] {
13+
all: unset;
14+
font: inherit;
15+
color: inherit;
16+
17+
cursor: pointer;
18+
padding: 1em 0.5em;
19+
border-radius: 0.5em;
20+
border: 0.1em solid transparent;
21+
22+
font-weight: bold;
23+
color: #fff;
24+
background: #567;
25+
text-shadow: 0.1em 0.1em 0.1em #0008;
26+
box-shadow: 0.1em 0.1em 0.3em #0004;
27+
}
28+
[part~="button"]:hover { background: #678; }
29+
[part~="button"]:active { background: #456; }
30+
31+
[part~="button-login"] {
32+
all: unset;
33+
font: inherit;
34+
color: inherit;
35+
36+
cursor: pointer;
37+
padding: 1em 0.5em;
38+
border-radius: 0.5em;
39+
border: 0.1em solid transparent;
40+
41+
font-weight: bold;
42+
color: white;
43+
background: #0a0;
44+
text-shadow: 0.1em 0.1em 0.1em #0008;
45+
box-shadow: 0.1em 0.1em 0.3em #0004;
46+
}
47+
[part~="button-login"]:hover { background: #4a4; }
48+
[part~="button-login"]:active { background: #080; }
2649
}
27-
[part="button"]:hover { background: #678; }
28-
[part="button"]:active { background: #456; }
29-
30-
[part="button-login"] {
31-
all: unset;
32-
font: inherit;
33-
color: inherit;
34-
35-
cursor: pointer;
36-
padding: 1em 0.5em;
37-
border-radius: 0.5em;
38-
border: 0.1em solid transparent;
39-
40-
font-weight: bold;
41-
color: white;
42-
background: #0a0;
43-
text-shadow: 0.1em 0.1em 0.1em #0008;
44-
box-shadow: 0.1em 0.1em 0.3em #0004;
45-
}
46-
[part="button-login"]:hover { background: #4a4; }
47-
[part="button-login"]:active { background: #080; }
4850
}
4951
5052
`

s/app/lib/ui/auth-button/style.css.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {css} from "lit"
33
export default css`@layer view {
44
55
:host {
6-
display: contents;
6+
display: inline-flex;
77
}
88
99
slot {

s/app/lib/ui/auth-button/view.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import styleCss from "./style.css.js"
55
import {Auth} from "../../parts/auth.js"
66

77
export const AuthButton = (auth: Auth) => view(use => () => {
8+
use.name("auth-button")
89
use.css(auth.theme, styleCss)
910
const attrs = use.attrs.spec({src: String})
11+
use.states().assign(auth.login ? "authenticated" : "unauthenticated")
1012

1113
async function clickLogout() {
1214
await auth.logout()

s/app/lib/ui/auth-user/style.css.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {css} from "lit"
33
export default css`@layer view {
44
55
:host {
6-
display: contents;
6+
display: inline-flex;
77
--icon-size: var(--auth-user-icon-size, 3em);
88
--label-max-width: var(--auth-user-label-max-width, 4em);
99
}
@@ -16,10 +16,12 @@ export default css`@layer view {
1616
1717
padding: 1em;
1818
border-radius: 0.5em;
19-
background: #333;
19+
color: color-mix(in oklab, var(--idcolor), #fff 80%);
20+
background: color-mix(in oklab, var(--idcolor), #4448 90%);
2021
}
2122
2223
.icon {
24+
color: var(--idcolor, white);
2325
svg {
2426
width: var(--icon-size);
2527
height: var(--icon-size);

s/app/lib/ui/auth-user/view.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ import {idHsl} from "../../../../common/utils/id-hue.js"
88
import userIcon from "../../../../common/ui/icons/tabler/user.icon.js"
99

1010
export const AuthUser = (auth: Auth) => view(use => () => {
11+
use.name("auth-user")
1112
use.css(auth.theme, styleCss)
13+
use.states().assign(auth.login ? "authenticated" : "unauthenticated")
1214

1315
if (!auth.login)
14-
return html``
16+
return null
1517

1618
const {id, label} = auth.login.nametag
19+
const idcolor = idHsl(id)
1720

1821
return html`
19-
<div part=shell>
20-
<div class=icon style="color: ${idHsl(id)};">
22+
<div part=shell style="--idcolor: ${idcolor};">
23+
<div class=icon>
2124
${svgLit(userIcon)}
2225
</div>
2326
<div class=box>

s/themes/basic.css

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)