Skip to content

Commit

Permalink
feat: add view source button
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Feb 22, 2024
1 parent 148bd22 commit 0fef0a3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/component/LucideIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Search as SearchIcon,
ZoomIn,
RefreshCcwDot,
Code2,
} from 'lucide'
import { For } from 'solid-js'
import { Dynamic } from 'solid-js/web'
Expand Down Expand Up @@ -55,3 +56,7 @@ export const AddToSearch = (props: LucideProps) => (
export const AppUpdateRequired = (props: LucideProps) => (
<LucideIcon icon={RefreshCcwDot} {...props} />
)

export const ViewSourceIcon = (props: LucideProps) => (
<LucideIcon icon={Code2} {...props} />
)
12 changes: 11 additions & 1 deletion src/component/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Sidebar as AppUpdateRequiredSidebar,
} from './AppUpdate.jsx'
import { DeviceSidebar } from './DeviceSidebar.js'
import { Search, Warning } from './LucideIcon.js'
import { Search, ViewSourceIcon, Warning } from './LucideIcon.js'
import { Sidebar as SearchSidebar } from './Search.js'
import './Sidebar.css'
import { WIPSidebar } from './WIPSidebar.jsx'
Expand Down Expand Up @@ -41,6 +41,7 @@ const SidebarNav = () => (
<DeviceDetailButton />
<WarningButton />
<AppUpdateRequiredButton />
<ViewSourceButton />
</nav>
)

Expand Down Expand Up @@ -103,3 +104,12 @@ const WarningButton = () => {
</>
)
}

const ViewSourceButton = () => (
<>
<a class="button" href={REPOSITORY_URL} target="_blank">
<ViewSourceIcon strokeWidth={2} />
</a>
<hr />
</>
)
1 change: 1 addition & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ declare const BUILD_TIME: string
declare const REGISTRY_ENDPOINT: string
// Base URL of the site without a trailing slash
declare const BASE_URL: string
declare const REPOSITORY_URL: string
12 changes: 7 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { fromEnv } from '@nordicsemiconductor/from-env'
import fs from 'fs'
import { defineConfig } from 'vite'
import solidPlugin from 'vite-plugin-solid'
import path from 'node:path'
import { trimTrailingSlash } from './src/util/trimTrailingSlash.js'
import pJson from './package.json'

const { version: defaultVersion, homepage } = JSON.parse(
fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8'),
)
const {
version: defaultVersion,
homepage,
repository: { url: repositoryUrl },
} = pJson
const version = process.env.VERSION ?? defaultVersion
const { registryEndpoint } = fromEnv({
registryEndpoint: 'REGISTRY_ENDPOINT',
Expand All @@ -34,5 +35,6 @@ export default defineConfig({
BUILD_TIME: JSON.stringify(new Date().toISOString()),
REGISTRY_ENDPOINT: JSON.stringify(new URL(registryEndpoint).toString()),
BASE_URL: JSON.stringify(base),
REPOSITORY_URL: JSON.stringify(repositoryUrl.replace('git+', '')),
},
})

0 comments on commit 0fef0a3

Please sign in to comment.