Skip to content

Render natively ngui #1183

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions packages/ui/locales/en/views.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"repos": {
"create-new-file-no-plus": "Create new file",
"upload-files": "Upload files",
"search": "Search",
"summary": "Summary",
"files": "Files",
Expand Down Expand Up @@ -30,6 +28,7 @@
"findTag": "Find a tag",
"allCommits": "All commits",
"noFile": "No files available",
"create-new-file-no-plus": "Create new file",
"name": "Name",
"lastCommit": "Last commit message",
"date": "Date",
Expand Down Expand Up @@ -170,6 +169,7 @@
"creatingWebhook": "Creating webhook...",
"updateWebhook": "Update webhook",
"createWebhook": "Create webhook",
"upload-files": "Upload files",
"tagger": "Tagger",
"renameBranch": "Rename Branch",
"add": "Add",
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/locales/es/views.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"repos": {
"create-new-file-no-plus": "Crear nuevo archivo",
"upload-files": "Subir archivos",
"search": "Search",
"summary": "Summary",
"files": "Files",
Expand Down Expand Up @@ -30,6 +28,7 @@
"findTag": "Find a tag",
"allCommits": "All commits",
"noFile": "No files available",
"create-new-file-no-plus": "Crear nuevo archivo",
"name": "Name",
"lastCommit": "Last commit message",
"date": "Date",
Expand Down Expand Up @@ -170,6 +169,7 @@
"creatingWebhook": "Creating webhook...",
"updateWebhook": "Update webhook",
"createWebhook": "Create webhook",
"upload-files": "Subir archivos",
"tagger": "Tagger",
"renameBranch": "Rename Branch",
"add": "Add",
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/locales/fr/views.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"repos": {
"create-new-file-no-plus": "Créer un nouveau fichier",
"upload-files": "Télécharger des fichiers",
"search": "Rechercher",
"summary": "Résumé",
"files": "Fichiers",
Expand Down Expand Up @@ -30,6 +28,7 @@
"findTag": "Trouver une étiquette",
"allCommits": "Tous les commits",
"noFile": "Aucun fichier disponible",
"create-new-file-no-plus": "Créer un nouveau fichier",
"name": "Nom",
"lastCommit": "Dernier commit",
"date": "Date",
Expand Down Expand Up @@ -170,6 +169,7 @@
"creatingWebhook": "Creating webhook...",
"updateWebhook": "Update webhook",
"createWebhook": "Create webhook",
"upload-files": "Télécharger des fichiers",
"tagger": "Tagger",
"renameBranch": "Renommer la branche",
"add": "Ajouter",
Expand Down
30 changes: 10 additions & 20 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
{
"name": "@harnessio/ui",
"name": "@harnessio/ui-alt",
"description": "Harness Canary UI component library",
"version": "0.0.1-alpha.21",
"private": false,
"type": "module",
"main": "./dist/index.js",
"exports": {
"./components": "./dist/components.js",
"./views": "./dist/views.js",
"./utils": "./dist/utils.js",
"./hooks": "./dist/hooks.js",
"./locales": "./dist/locales.js",
"./tailwind.config": "./dist/tailwind.config.js",
"./styles.css": "./dist/styles.css",
"./shared-style-variables.css": "./src/shared-style-variables.css",
"./markdown-preview-styles.css": "./src/components/markdown-viewer/style.css",
"./context": "./dist/context.js",
"./types": "./dist/types.js"
},
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"style": "./dist/styles.css",
"files": [
"dist/**.*",
"src/shared-style-variables.css",
"src/components/markdown-viewer/style.css"
"dist/*"
],
"scripts": {
"dev": "vite",
"build": "vite build && pnpm extract",
"build:ci": "vite build --config ./vite-base.config.ts",
"build:analyse": "vite build --config ./vite-analyse.config.ts",
"build:watch": "vite build --watch --emptyOutDir=false",
"build:custom": "vite build --config ./vite-custom.config.ts",
"lint": "eslint ./src",
"pretty": "prettier --check ./src",
"shadcn:update": "npx shadcn-ui@latest add -a -o -y",
"prepublishOnly": "pnpm build",
"publish:custom": "pnpm build:custom && yalc publish --no-scripts",
"pre-commit": "lint-staged",
"test": "vitest --run",
"test:coverage": "vitest --run --coverage",
Expand All @@ -41,9 +31,9 @@
"typecheck": "tsc -b",
"extract": "i18next --config './i18n.config.ts'"
},
"types": "./dist/index.d.ts",
"style": "./dist/styles.css",
"sideEffects": false,
"sideEffects": [
"**/*.css"
],
"repository": {
"type": "git",
"url": "https://github.com/harness/canary.git"
Expand Down
99 changes: 50 additions & 49 deletions packages/ui/src/components/commit-copy-actions.tsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
import { useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'
// import { useEffect, useState } from 'react'

import { Icon, ShaBadge } from '@/components'
import copy from 'clipboard-copy'
// // import { useNavigate } from 'react-router-dom'

export const CommitCopyActions = ({
sha,
toCommitDetails
}: {
sha: string
toCommitDetails?: ({ sha }: { sha: string }) => string
}) => {
const [copied, setCopied] = useState(false)
const navigate = useNavigate()
// import { Icon, ShaBadge } from '@/components'
// import copy from 'clipboard-copy'

useEffect(() => {
let timeoutId: number
if (copied) {
copy(sha)
timeoutId = window.setTimeout(() => setCopied(false), 2500)
}
return () => {
clearTimeout(timeoutId)
}
}, [copied, sha])
// export const CommitCopyActions = ({
// sha,
// toCommitDetails
// }: {
// sha: string
// toCommitDetails?: ({ sha }: { sha: string }) => string
// }) => {
// const [copied, setCopied] = useState(false)
// const navigate = useNavigate()

const handleNavigation = () => {
navigate(toCommitDetails?.({ sha: sha || '' }) || '')
}
// useEffect(() => {
// let timeoutId: number
// if (copied) {
// copy(sha)
// timeoutId = window.setTimeout(() => setCopied(false), 2500)
// }
// return () => {
// clearTimeout(timeoutId)
// }
// }, [copied, sha])

return (
<ShaBadge.Root>
<ShaBadge.Content className="p-0" asChild>
<button
className="size-full px-2.5 text-13 text-foreground-3"
onClick={() => handleNavigation()}
onKeyDown={e => {
if (e.key === 'Enter' || e.key === ' ') handleNavigation()
}}
>
{sha.substring(0, 7)}
</button>
</ShaBadge.Content>
<ShaBadge.Icon
handleClick={() => {
setCopied(true)
}}
>
<Icon size={16} name={copied ? 'tick' : 'clone'} className="text-icons-3" />
</ShaBadge.Icon>
</ShaBadge.Root>
)
}
// const handleNavigation = () => {
// navigate(toCommitDetails?.({ sha: sha || '' }) || '')
// }

// return (
// <ShaBadge.Root>
// <ShaBadge.Content className="p-0" asChild>
// <button
// className="size-full px-2.5 text-13 text-foreground-3"
// onClick={() => handleNavigation()}
// onKeyDown={e => {
// if (e.key === 'Enter' || e.key === ' ') handleNavigation()
// }}
// >
// {sha.substring(0, 7)}
// </button>
// </ShaBadge.Content>
// <ShaBadge.Icon
// handleClick={() => {
// setCopied(true)
// }}
// >
// <Icon size={16} name={copied ? 'tick' : 'clone'} className="text-icons-3" />
// </ShaBadge.Icon>
// </ShaBadge.Root>
// )
// }
86 changes: 43 additions & 43 deletions packages/ui/src/components/file-additions-trigger.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
import { FC, useRef } from 'react'
import { Link } from 'react-router-dom'
// import { FC, useRef } from 'react'
// import { Link } from 'react-router-dom'

import { Button, DropdownMenu, Icon } from '@/components'
import { TranslationStore } from '@/views'
// import { Button, DropdownMenu, Icon } from '@/components'
// import { TranslationStore } from '@/views'

export interface FileAdditionsTriggerProps {
useTranslationStore: () => TranslationStore
pathNewFile: string
pathUploadFiles: string
}
// export interface FileAdditionsTriggerProps {
// useTranslationStore: () => TranslationStore
// pathNewFile: string
// pathUploadFiles: string
// }

export const FileAdditionsTrigger: FC<FileAdditionsTriggerProps> = ({
useTranslationStore,
pathNewFile,
pathUploadFiles
}) => {
const triggerRef = useRef<HTMLButtonElement>(null)
const { t } = useTranslationStore()
// export const FileAdditionsTrigger: FC<FileAdditionsTriggerProps> = ({
// useTranslationStore,
// pathNewFile,
// pathUploadFiles
// }) => {
// const triggerRef = useRef<HTMLButtonElement>(null)
// const { t } = useTranslationStore()

return (
<DropdownMenu.Root>
<DropdownMenu.Trigger asChild ref={triggerRef}>
<Button className="relative overflow-hidden pl-4 pr-8" variant="outline">
<span className="border-r pr-2.5">{t('views:repos.create-new-file-no-plus', 'Create new file')}</span>
<span className="absolute right-0 top-0 flex h-full w-8 items-center justify-center text-icons-7 transition-colors group-data-[state=open]:bg-background-3 group-data-[state=open]:text-icons-9">
<Icon name="chevron-down" size={12} />
</span>
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content className="min-w-[157px]" align="end">
<DropdownMenu.Item>
<Link className="relative grid grid-cols-[auto_1fr] items-center gap-1.5" to={pathNewFile}>
<Icon name="plus" size={12} />
<span className="truncate">{t('views:repos.create-new-file-no-plus', 'Create new file')}</span>
</Link>
</DropdownMenu.Item>
<DropdownMenu.Item>
<Link className="relative grid grid-cols-[auto_1fr] items-center gap-1.5" to={pathUploadFiles}>
<Icon name="upload" size={12} />
<span className="truncate">{t('views:repos.upload-files', 'Upload files')}</span>
</Link>
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>
)
}
// return (
// <DropdownMenu.Root>
// <DropdownMenu.Trigger asChild ref={triggerRef}>
// <Button className="relative overflow-hidden pl-4 pr-8" variant="outline">
// <span className="border-r pr-2.5">{t('views:repos.create-new-file-no-plus', 'Create new file')}</span>
// <span className="absolute right-0 top-0 flex h-full w-8 items-center justify-center text-icons-7 transition-colors group-data-[state=open]:bg-background-3 group-data-[state=open]:text-icons-9">
// <Icon name="chevron-down" size={12} />
// </span>
// </Button>
// </DropdownMenu.Trigger>
// <DropdownMenu.Content className="min-w-[157px]" align="end">
// <DropdownMenu.Item>
// <Link className="relative grid grid-cols-[auto_1fr] items-center gap-1.5" to={pathNewFile}>
// <Icon name="plus" size={12} />
// <span className="truncate">{t('views:repos.create-new-file-no-plus', 'Create new file')}</span>
// </Link>
// </DropdownMenu.Item>
// <DropdownMenu.Item>
// <Link className="relative grid grid-cols-[auto_1fr] items-center gap-1.5" to={pathUploadFiles}>
// <Icon name="upload" size={12} />
// <span className="truncate">{t('views:repos.upload-files', 'Upload files')}</span>
// </Link>
// </DropdownMenu.Item>
// </DropdownMenu.Content>
// </DropdownMenu.Root>
// )
// }
Loading
Loading