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

Show beta info in header #340

Merged
merged 6 commits into from
Feb 1, 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
24 changes: 24 additions & 0 deletions ui/src/components/header/beta-info/beta-info.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import 'src/design-system/variables/variables.scss';
@import 'src/design-system/variables/colors.scss';
@import 'src/design-system/variables/typography.scss';

.wrapper {
display: flex;
align-items: center;
justify-content: center;
gap: 16px;
}

.badge {
padding: 4px 16px;
border-radius: 4px;
background-color: $color-success-100;
color: $color-success-700;
text-align: center;
@include label();
}

.version {
@include paragraph-x-small();
white-space: nowrap;
}
19 changes: 19 additions & 0 deletions ui/src/components/header/beta-info/beta-info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Tooltip } from 'design-system/components/tooltip/tooltip'
import styles from './beta-info.module.scss'

const COPY = {
LABEL: 'Beta',
INFO: 'All data is considered test data and may be changed or deleted at any time. Use with caution.',
VERSION: `Build ${__COMMIT_HASH__}`,
}

export const BetaInfo = () => {
return (
<div className={styles.wrapper}>
<Tooltip content={COPY.INFO}>
<div className={styles.badge}>{COPY.LABEL}</div>
</Tooltip>
<span className={styles.version}>{COPY.VERSION}</span>
</div>
)
}
16 changes: 14 additions & 2 deletions ui/src/components/header/header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
height: 64px;
display: flex;
align-items: center;
justify-content: space-between;
justify-content: flex-start;
gap: 32px;
padding: 0 100px;
background-color: $color-generic-white;
border-bottom: 1px solid $color-neutral-100;
Expand All @@ -22,12 +23,18 @@
vertical-align: middle;
}

.infoPages {
.rightContent {
display: flex;
align-items: center;
justify-content: flex-end;
flex: 1;
gap: 4px;
}

.infoPages {
display: contents;
}

@media only screen and (max-width: $medium-screen-breakpoint) {
.header {
padding: 0 32px;
Expand All @@ -37,5 +44,10 @@
@media only screen and (max-width: $small-screen-breakpoint) {
.header {
padding: 0 16px;
gap: 16px;
}

.infoPages {
display: none;
}
}
12 changes: 8 additions & 4 deletions ui/src/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { STRING, translate } from 'utils/language'
import { usePageTitle } from 'utils/usePageTitle'
import { useUser } from 'utils/user/userContext'
import ami from './ami.png'
import { BetaInfo } from './beta-info/beta-info'
import styles from './header.module.scss'
import { UserInfoDialog } from './user-info-dialog/user-info-dialog'

Expand All @@ -31,10 +32,13 @@ export const Header = () => {
className={styles.logo}
/>
</Link>
<div className={styles.infoPages}>
{pages.map((page) => (
<InfoDialog key={page.id} name={page.name} slug={page.slug} />
))}
<BetaInfo />
<div className={styles.rightContent}>
<div className={styles.infoPages}>
{pages.map((page) => (
<InfoDialog key={page.id} name={page.name} slug={page.slug} />
))}
</div>
<Button
label={translate(STRING.SIGN_UP)}
theme={ButtonTheme.Plain}
Expand Down
2 changes: 1 addition & 1 deletion ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"baseUrl": "src",
"types": ["vite/client", "vite-plugin-svgr/client"]
},
"include": ["src"]
"include": ["src", "vite-env.d.ts"]
}
2 changes: 2 additions & 0 deletions ui/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/// <reference types="vite/client" />

declare const __COMMIT_HASH__: string
8 changes: 8 additions & 0 deletions ui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import react from '@vitejs/plugin-react'
import childProcees from 'child_process'
import { defineConfig } from 'vite'
import eslint from 'vite-plugin-eslint'
import svgr from 'vite-plugin-svgr'
import viteTsconfigPaths from 'vite-tsconfig-paths'

const commitHash = childProcees
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's cool!

.execSync('git rev-parse --short HEAD')
.toString()

export default defineConfig({
base: '/',
build: {
Expand All @@ -15,6 +20,9 @@ export default defineConfig({
svgr({ include: '**/*.svg?react' }),
eslint({ exclude: ['/virtual:/**', 'node_modules/**'] }),
],
define: {
__COMMIT_HASH__: JSON.stringify(commitHash),
},
server: {
open: true,
port: 3000,
Expand Down