Skip to content

Commit

Permalink
format, lint
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterStorey committed Oct 3, 2024
1 parent 197bf7c commit f207053
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 401 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- [2024-10-02] [format, lint](https://github.com/RubricLab/ui/commit/c63735f98ceded961f2f4cb601111afb6b8c5e03)
- [2024-10-02] [refactor to new biome](https://github.com/RubricLab/ui/commit/8d2aeca6c0ae824b8bcf1f85a7bd1fecda84180e)
- [2024-10-02] [Again again](https://github.com/RubricLab/ui/commit/ad0f01623966ed33b238a56e1726d89e3e1ed029)
- [2024-10-02] [Bundle css](https://github.com/RubricLab/ui/commit/343655090d6f68bf065807a4552a655a5b660517)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rubriclab/ui",
"version": "5.0.10",
"version": "5.0.11",
"main": "dist/index.js",
"types": "src/index.ts",
"description": "UI package by Rubric Labs",
Expand Down
40 changes: 17 additions & 23 deletions src/components/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"use client";
'use client'

import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { forwardRef } from "react";
import * as AccordionPrimitive from '@radix-ui/react-accordion'
import { forwardRef } from 'react'

import { cn } from "../utils/cn";
import { cn } from '../utils/cn'

const Accordion = AccordionPrimitive.Root;
const Accordion = AccordionPrimitive.Root

const AccordionItem = forwardRef<
React.ElementRef<typeof AccordionPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
>(({ className, ...props }, ref) => (
<AccordionPrimitive.Item
ref={ref}
className={cn("border-b border-b-rubricui-contrast/10", className)}
className={cn('border-b border-b-rubricui-contrast/10', className)}
{...props}
/>
));
AccordionItem.displayName = "AccordionItem";
))
AccordionItem.displayName = 'AccordionItem'

const AccordionTrigger = forwardRef<
React.ElementRef<typeof AccordionPrimitive.Trigger>,
Expand All @@ -27,19 +27,13 @@ const AccordionTrigger = forwardRef<
<AccordionPrimitive.Trigger
ref={ref}
className={cn(
"flex flex-1 items-center justify-between py-4 font-medium text-rubricui-contrast transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
className,
'flex flex-1 items-center justify-between py-4 font-medium text-rubricui-contrast transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
className
)}
{...props}
>
{children}
<svg
width="15"
height="15"
viewBox="0 0 15 15"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<title>Accordion Icon</title>
<path
d="M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z"
Expand All @@ -49,8 +43,8 @@ const AccordionTrigger = forwardRef<
</svg>
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
));
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
))
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName

const AccordionContent = forwardRef<
React.ElementRef<typeof AccordionPrimitive.Content>,
Expand All @@ -61,10 +55,10 @@ const AccordionContent = forwardRef<
className="overflow-hidden text-rubricui-contrast text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
{...props}
>
<div className={cn("pt-0 pb-4", className)}>{children}</div>
<div className={cn('pt-0 pb-4', className)}>{children}</div>
</AccordionPrimitive.Content>
));
))

AccordionContent.displayName = AccordionPrimitive.Content.displayName;
AccordionContent.displayName = AccordionPrimitive.Content.displayName

export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
72 changes: 30 additions & 42 deletions src/components/codeblock.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
"use client";
'use client'

import { Highlight, type PrismTheme, themes } from "prism-react-renderer";
import Prism from "prismjs";
import { useState } from "react";
import { cn } from "../utils/cn";
(typeof global !== "undefined" ? global : window).Prism = Prism;
require("prismjs/components/prism-python");
require("prismjs/components/prism-javascript");
require("prismjs/components/prism-json");
import { Highlight, type PrismTheme, themes } from 'prism-react-renderer'
import Prism from 'prismjs'
import { useState } from 'react'
import { cn } from '../utils/cn'
;(typeof global !== 'undefined' ? global : window).Prism = Prism
require('prismjs/components/prism-python')
require('prismjs/components/prism-javascript')
require('prismjs/components/prism-json')

const CodeBlock = ({
language,
children,
fileName,
className,
headerClassName,
theme = themes.github,
theme = themes.github
}: {
language: string;
children: string;
fileName?: string;
className?: string;
headerClassName?: string;
theme?: PrismTheme;
language: string
children: string
fileName?: string
className?: string
headerClassName?: string
theme?: PrismTheme
}) => {
const [copied, setCopied] = useState(false);
const [copied, setCopied] = useState(false)

const copyToClipboard = () => {
navigator.clipboard.writeText(children);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};
navigator.clipboard.writeText(children)
setCopied(true)
setTimeout(() => setCopied(false), 2000)
}

return (
<div className="overflow-hidden rounded-lg border border-rubricui-contrast/10">
{fileName && (
<div
className={cn(
"flex items-center justify-between bg-rubricui-contrast/10 px-4 py-2 text-rubricui-contrast",
headerClassName,
'flex items-center justify-between bg-rubricui-contrast/10 px-4 py-2 text-rubricui-contrast',
headerClassName
)}
>
<span className="font-mono text-xs">{fileName}</span>
Expand Down Expand Up @@ -79,25 +79,13 @@ const CodeBlock = ({
</button>
</div>
)}
<Highlight
theme={theme}
code={children}
language={language}
prism={Prism}
>
<Highlight theme={theme} code={children} language={language} prism={Prism}>
{({ tokens, getLineProps, getTokenProps }) => (
<pre
className={cn(
"m-0 overflow-x-auto p-4 text-sm dark:invert",
className,
)}
>
<pre className={cn('m-0 overflow-x-auto p-4 text-sm dark:invert', className)}>
<code>
{tokens.map((line, i) => (
<div key={i} {...getLineProps({ line })} className="table-row">
<span className="table-cell select-none pr-4 text-right opacity-50">
{i + 1}
</span>
<span className="table-cell select-none pr-4 text-right opacity-50">{i + 1}</span>
<span className="table-cell">
{line.map((token, key) => (
<span key={key} {...getTokenProps({ token })} />
Expand All @@ -110,9 +98,9 @@ const CodeBlock = ({
)}
</Highlight>
</div>
);
};
)
}

CodeBlock.displayName = "CodeBlock";
CodeBlock.displayName = 'CodeBlock'

export { CodeBlock };
export { CodeBlock }
Loading

0 comments on commit f207053

Please sign in to comment.