Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update button and tooltip content and UI #7

Merged
merged 7 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,39 @@ Check the page that opens if the Header is properly rendered and if the latest p

It will create a `build` folder with the compiled assets.

## URL
## How to use

https://traefik.github.io/traefiklabs-hub-button-app/main-v1.js
https://traefik.github.io/traefiklabs-hub-button-app/main-v1.js.map
Put the full URL of the script file in the `src` attribute of a `<script>` tag:

```html
<script src="https://traefik.github.io/traefiklabs-hub-button-app/main-v1.js"></script>
```

You can place the script reference in head or body tag, as you like.

Then, you can use the **hub-button-app** custom element wherever you need it.
Please notice the custom element exposes a property called **theme** to control its appearance; possible values can be
`dark` or `light`, with light as the default value.

### Embed into another project (local fallback)

The script (and its sourcemap) can be embedded in another project codebase, this can be useful as a local fallback in
case the remote source became unavailable.

To make the static assets on your computer please run `make static-assets`.

Please notice that in macOS `''` must be added after `-i` in each sed command, e.g.
`sed -i 's@something@something@' dest.file` become `sed -i '' 's@something@something@' dest.file`.

When you have the static assets available please remember to update, in both the script and its sourcemap, the following
lines:

| File | Line | Key |
| - | - | - |
| main-v1.js | 3 | `sourceMappingURL` |
| main-v1.js.map | 1 | `file` |

### Deployment URLs

- https://traefik.github.io/traefiklabs-hub-button-app/main-v1.js
- https://traefik.github.io/traefiklabs-hub-button-app/main-v1.js.map
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
point this script src to the local build
-->
<script
type="text/javascript"
type="text/babel"
src="/build/static/js/"
></script>
<!--
Expand Down
14 changes: 11 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import HubButton from 'components/HubButton'
import { darkTheme, lightTheme } from 'components/themes'
import { useMemo } from 'react'
import { ThemeProvider } from 'styled-components'

export const App = ({ theme = 'light' }: { theme?: string }) => {
export const App = ({ theme = 'light' }: { theme?: 'light' | 'dark' }) => {
const safeTheme = useMemo(() => {
if (!['light', 'dark'].includes(theme)) {
return 'light'
}
return theme
}, [theme])

return (
<ThemeProvider theme={theme === 'dark' ? darkTheme : lightTheme}>
<HubButton />
<ThemeProvider theme={safeTheme === 'dark' ? darkTheme : lightTheme}>
<HubButton theme={safeTheme} />
</ThemeProvider>
)
}
Expand Down
Loading
Loading