Skip to content

Commit

Permalink
feat: add lucide icons
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Feb 20, 2024
1 parent cca88d8 commit ee06d3f
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 31 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Share+Tech&display=swap"
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300&family=Share+Tech&family=Share+Tech+Mono&display=swap"
rel="stylesheet"
/>
<title>hello.nrfcloud.com/map</title>
<base href="/map" />
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
8 changes: 7 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
},
"dependencies": {
"@hello.nrfcloud.com/proto": "6.4.15",
"date-fns": "3.3.1"
"date-fns": "3.3.1",
"lucide": "0.335.0"
},
"engines": {
"node": ">=20.0.0",
Expand Down
2 changes: 0 additions & 2 deletions src/MapApp.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Devices } from './component/Devices.jsx'
import { ExperimentalWarning } from './component/ExperimentalWarning.jsx'
import { Sidebar } from './component/Sidebar.jsx'

import './MapApp.css'
Expand All @@ -8,7 +7,6 @@ export const MapApp = () => {
return (
<>
<Sidebar />
<ExperimentalWarning />
<main>
<Devices />
</main>
Expand Down
25 changes: 24 additions & 1 deletion src/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
--bg-blue-6: #021255;
--bg-blue-7: #020e4b;
--bg-blue-8: #020d47;
--color-warning: #e7c27b;
--color-dark-red: #860404;
}

html,
Expand All @@ -18,7 +20,28 @@ body {
background: var(--bg-blue-8);
color: white;
font-family: "Share Tech", sans-serif;
font-weight: 400;
font-style: normal;
}

h1 {
code {
font-family: "Share Tech Mono", monospace;
font-weight: 400;
font-style: normal;
}

button[type="button"] {
cursor: pointer;
}

h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Montserrat", sans-serif;
font-optical-sizing: auto;
font-weight: 300;
font-style: normal;
}
1 change: 0 additions & 1 deletion src/component/Devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const DescribeInstance = ({ instance }: { instance: LwM2MObjectInstance }) => {
const definition = definitions[instance.ObjectID as LwM2MObjectID]
const tsResourceId = timestampResources[definition.ObjectID] as number
const ts = instance.Resources[tsResourceId] as string
console.log(ts)
return (
<Show
when={definition !== undefined}
Expand Down
14 changes: 0 additions & 14 deletions src/component/ExperimentalWarning.css

This file was deleted.

7 changes: 0 additions & 7 deletions src/component/ExperimentalWarning.tsx

This file was deleted.

39 changes: 39 additions & 0 deletions src/component/LucideIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { AlertTriangle, X, type IconNode } from 'lucide'
import { For } from 'solid-js'
import { Dynamic } from 'solid-js/web'

export const LucideIcon = ({
icon,
strokeWidth,
size,
}: {
icon: IconNode
} & LucideProps) => {

Check warning on line 11 in src/component/LucideIcon.tsx

View workflow job for this annotation

GitHub Actions / main

Missing return type on function
const [, attrs, children] = icon
const svgProps = {
'stroke-width': strokeWidth ?? attrs.strokeWidth ?? 2,
}
return (
<svg
{...{ ...attrs, ...svgProps }}
style={{ width: `${size ?? 24}px`, height: `${size ?? 24}px` }}
>
<For each={children}>
{([elementName, attrs]) => (
<Dynamic component={elementName} {...attrs} />
)}
</For>
</svg>
)
}

export type LucideProps = {
size?: number
strokeWidth?: number
}

export const Warning = (props: LucideProps) => (

Check warning on line 35 in src/component/LucideIcon.tsx

View workflow job for this annotation

GitHub Actions / main

Missing return type on function
<LucideIcon icon={AlertTriangle} {...props} />
)

export const Close = (props: LucideProps) => <LucideIcon icon={X} {...props} />

Check warning on line 39 in src/component/LucideIcon.tsx

View workflow job for this annotation

GitHub Actions / main

Missing return type on function
45 changes: 44 additions & 1 deletion src/component/Sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,51 @@ nav.sidebar .logo {
}

nav.sidebar hr {
border-top: 1px solid var(--bg-blue-8);
border-bottom: 1px solid var(--bg-blue-1);
width: 100%;
padding: 0;
}

nav.sidebar .button {
width: 59px;
height: 59px;
display: flex;
align-items: center;
justify-content: center;
}

nav.sidebar .warning {
background-color: var(--color-warning);
color: var(--color-dark-red);
}

nav.sidebar .white {
background-color: white;
}

aside.sidebar {
position: fixed;
left: 59px;
top: 60px;
}

aside.sidebar > header {
display: flex;
justify-content: space-between;
align-items: center;
height: 60px;
margin: 0 1rem;
}

aside.sidebar.warning {
background-color: var(--color-warning);
color: var(--color-dark-red);

min-height: 50vh;
}

@media (min-width: 400px) {
aside.sidebar.warning {
width: 300px;
}
}
47 changes: 45 additions & 2 deletions src/component/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
import './Sidebar.css'
import { createSignal, Show, onCleanup, type ParentProps } from 'solid-js'
import { Close, Warning } from './LucideIcon.js'

export const Sidebar = () => (
export const Sidebar = () => {

Check warning on line 5 in src/component/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / main

Missing return type on function
const [location, setLocation] = createSignal(
window.location.hash.slice(1) || 'home',
)

const locationHandler = () => setLocation(window.location.hash.slice(1))
window.addEventListener('hashchange', locationHandler)

onCleanup(() => window.removeEventListener('hashchange', locationHandler))

return (
<>
<SidebarNav />
<Show when={location() === 'warning'}>
<SidebarContent class="warning">
<header>
<h1>Under construction!</h1>
<a href="#">
<Close />
</a>
</header>

<div style={{ padding: '1rem' }}>
<p>
This website is under construction and not intended for production
use.
</p>
</div>
</SidebarContent>
</Show>
</>
)
}

const SidebarContent = (props: ParentProps<{ class?: string }>) => (
<aside class={`sidebar ${props.class ?? ''}`}>{props.children}</aside>
)

const SidebarNav = () => (
<nav class="sidebar">
<a href="/map">
<a href="#" class="button white">
<img src="/assets/logo.svg" class="logo" alt="hello.nrfcloud.com logo" />
</a>
<hr />
<a class="button warning" href="#warning">
<Warning strokeWidth={2} size={32} />
</a>
</nav>
)

0 comments on commit ee06d3f

Please sign in to comment.