web: patternfly hints as ak-web-component#7120
Conversation
Patternfly 5's "Hints" React Component, but ported to web components. The discovery that CSS Custom Properties are still available in child components, even if they're within independent ShadowDOMs, made this fairly easy to port from Handlebars to Lit-HTML. Moving the definitions into `:host` and the applications into the root DIV of the component made duplicating the Patternfly 5 structure straightforward. Despite the [Patternfly Elements]documentation](https://patternflyelements.org/docs/develop/create/), there's a lot to Patternfly Elements that isn't well documented, such as their slot controller, which near as I can tell just makes it easy to determine if a slot with the given name is actually being used by the client code, but it's hard to tell why, other than that it provides an easy way to determine if some CSS should be included.
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for authentik ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for authentik ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7120 +/- ##
=======================================
Coverage 92.67% 92.67%
=======================================
Files 568 568
Lines 28049 28049
=======================================
Hits 25991 25991
Misses 2058 2058
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
* main: (22 commits) lifecycle: fix install_id migration not running (#7116) core: bump Go from 1.20 to 1.21 (#7117) providers/ldap: add windows adsi support (#7098) web: bump API Client version (#7113) translate: Updates for file web/xliff/en.xlf in zh-Hans on branch main (#7112) translate: Updates for file web/xliff/en.xlf in zh_CN on branch main (#7111) web: bump the wdio group in /tests/wdio with 4 updates (#7108) core/api: add uuid field to core api user http response (#7110) core: bump goauthentik.io/api/v3 from 3.2023083.4 to 3.2023083.5 (#7105) core: bump golang.org/x/oauth2 from 0.12.0 to 0.13.0 (#7106) web: bump the eslint group in /tests/wdio with 1 update (#7107) providers/proxy: improve SLO by backchannel logging out sessions (#7099) web: bump @rollup/plugin-node-resolve from 15.2.2 to 15.2.3 in /web (#7104) web: bump the eslint group in /web with 1 update (#7103) web: bump the storybook group in /web with 1 update (#7102) web: bump API Client version (#7101) providers/saml: add default RelayState value for IDP-initiated requests (#7100) lifecycle: improve reliability of system migrations (#7089) sources/ldap: fix attribute path resolution (#7090) root: Ignore the vendor folder (#7094) ...
BeryJu
left a comment
There was a problem hiding this comment.
Looks good, the only thing its missing is a darker background when using the dark theme, maybe something like --ak-dark-background-lighter (I tried to make this work with pure css myself but failed to get there)
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-web-hint-element-1697127313-4c28b69
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sFor arm64, use these values: AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-web-hint-element-1697127313-4c28b69-arm64
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-web-hint-element-1697127313-4c28b69For arm64, use these values: authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-web-hint-element-1697127313-4c28b69-arm64Afterwards, run the upgrade commands from the latest release notes. |
* main: web: bump pyright from 1.1.330 to 1.1.331 in /web (#7143) core: bump golang from 1.21.2-bookworm to 1.21.3-bookworm (#7142) core: bump gitpython from 3.1.35 to 3.1.37 (#7140) core: bump goauthentik.io/api/v3 from 3.2023083.5 to 3.2023083.6 (#7124) website/docs: fix PowerDNS Docker Hub repo name (#7134) website/blog: Fix typo in SCIM post (#7136) providers/proxy: fix redis cookies missing strict path (#7135) web: bump @lit-labs/task from 3.0.2 to 3.1.0 in /web (#7132) web: bump @lit/localize-tools from 0.6.10 to 0.7.0 in /web (#7133) web: bump the eslint group in /tests/wdio with 2 updates (#7128) core: bump structlog from 23.1.0 to 23.2.0 (#7125) core: bump selenium from 4.13.0 to 4.14.0 (#7126) web: bump the eslint group in /web with 2 updates (#7127) web: bump the wdio group in /tests/wdio with 4 updates (#7129)
Add the `ShowHintController`. This ReactiveController takes a token in its constructor, and looks in LocalStorage for that token and an associated value. If that value is not `undefined`, it sets the field `this.host.showHint` to the value found. It also provides a `render()` method that provides an `ak-hint-footer` with a checkbox and the "Don't show this message again," and responds to clicks on the checkbox by setting the `this.hint.showHint` and LocalStorage values to "false". An example web component using it has been supplied.
This was nifty. Still not entirely sure about the `theme="dark"`
rippling through the product, but in this case it works quite well.
All it took was defining the alternative dark mode values in a CSS
entry, `:host([theme="dark"]) { ... }` and exploiting Patternfly's
already intensely atomized CSS Custom Properties properly.
|
|
||
| import PFPage from "@patternfly/patternfly/components/Page/page.css"; | ||
|
|
||
| @customElement("ak-application-wizard-hint") |
There was a problem hiding this comment.
If this pattern of showHint; hintController; hintController.render() becomes commonplace enough, it might behoove us to extract that into an abstract ShowHintHost class, but not today, Satan, not today. :-)
| ); | ||
| } | ||
|
|
||
| :host([theme="dark"]) { |
There was a problem hiding this comment.
Once all the sub-components were receiving their styling instructions from this block, adding the host-with-attribute-match made it remarkably easy to get dark mode working.
Signed-off-by: Jens L. <jens@beryju.org>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
* main: web: patternfly hints as ak-web-component (#7120) web: fix form default submit handler (#7122) web/admin: add additional Flow info (#7155) tests: fix potential infinite wait in tests spinning up a container (#7153) ci: disable ghcr retention schedule while it's broken (#7154) translate: Updates for file locale/en/LC_MESSAGES/django.po in de (#7151) core: bump golang.org/x/net from 0.16.0 to 0.17.0 (#7148) web: bump the babel group in /web with 5 updates (#7149) core: bump sentry-sdk from 1.31.0 to 1.32.0 (#7150) website: make get started on pricing page go to customer portal (#7147)
* main: web: patternfly hints as ak-web-component (#7120) web: fix form default submit handler (#7122) web/admin: add additional Flow info (#7155) tests: fix potential infinite wait in tests spinning up a container (#7153) ci: disable ghcr retention schedule while it's broken (#7154) translate: Updates for file locale/en/LC_MESSAGES/django.po in de (#7151) core: bump golang.org/x/net from 0.16.0 to 0.17.0 (#7148) web: bump the babel group in /web with 5 updates (#7149) core: bump sentry-sdk from 1.31.0 to 1.32.0 (#7150) website: make get started on pricing page go to customer portal (#7147)

Details
Patternfly 5's "Hints" React Component, but ported to web components. The discovery that CSS Custom Properties are still available in child components, even if they're within independent ShadowDOMs, made this fairly easy to port from Handlebars to Lit-HTML. Moving the definitions into
:hostand the applications into the root DIV of the component made duplicating the Patternfly 5 structure straightforward.Despite the Patternfly Elements documentation, there's a lot to Patternfly Elements that isn't well documented, such as their slot controller, which near as I can tell just makes it easy to determine if a slot with the given name is actually being used by the client code, but it's hard to tell why, other than that it provides an easy way to determine if some CSS should be included.
This is a 1:1 port of the HBR files and SCSS to a Patternfly-Elements form. As such, there are probably a lot of edge cases using slotted content that I haven't addressed, but for the basic use cases we have in mind, it seems to work just fine.
Checklist
ak test authentik/)make lint-fix)If an API change has been made
make gen-build)If changes to the frontend have been made
make web)make i18n-extract)If applicable
make website)