Skip to content

Commit 797940e

Browse files
authored
Fix Letter spacing for fonts + Docs improvements (#998)
1 parent 9c347ac commit 797940e

File tree

9 files changed

+52
-60
lines changed

9 files changed

+52
-60
lines changed

.github/workflows/build-rad-ui.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ name: Build RAD UI
33
on:
44
pull_request:
55
branches: [ main, security-fixes ]
6-
6+
paths:
7+
- 'src/components/ui/**' # Only run when files in this directory change
8+
- 'styles/**'
9+
- 'package.json'
710
jobs:
811
build:
912
runs-on: ubuntu-latest

.github/workflows/chromatic.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches:
66
- main # Adjust this if your main branch has a different name
7+
paths:
8+
- 'src/components/ui/**' # Only run when files in this directory change
9+
- 'styles/**'
710
# pull_request: # No need for PRs for now
811
# branches:
912
# - main # Adjust this if your main branch has a different name

docs/app/docs/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ const Layout = ({ children }: Doc) => {
1818
</div>
1919
<div className='text-gray-1000 flex flex-col overflow-y-auto flex-1' id="docs-content">
2020
<div className=' p-4 md:mx-auto md:max-w-[1440px] w-full'>
21+
<div className="w-full max-w-screen-lg mx-auto">
2122
<PageDetails />
2223
{children}
2324
<EditPageOnGithub />
25+
</div>
26+
2427
</div>
2528
</div>
2629
</div>

docs/app/docs/page.mdx

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/app/globals.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
@import 'https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap';
45

6+
body {
7+
font-family: Inter, sans-serif;
8+
}
59

610

711

docs/components/layout/Documentation/Documentation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const RightArrow = () => {
2020
};
2121

2222
const Documentation = ({ title = '', description = '', currentPage = undefined, children }) => {
23-
return <div className='w-full max-w-screen-lg mx-auto'>
23+
return <div>
2424
<div>
2525
<div className='flex items-center space-x-4'>
2626
<BookMarkLink id={title}> <Heading>{title}</Heading> </BookMarkLink>

docs/components/layout/Documentation/helpers/CodeBlock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const CodeBlock = ({ children, language = 'jsx' }) => {
3838
.trim(); // Remove leading/trailing whitespace
3939

4040
return (
41-
<pre className="relative">
41+
<pre className="relative mb-8">
4242
<code className={`language-${language} whitespace-pre-wrap`} style={{ wordBreak: 'break-word' }}>{code}</code>
4343
<span className="absolute top-2 right-2">
4444
<Tooltip label="Copy" placement="bottom">

src/components/ui/Heading/Heading.tsx

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,46 @@ import React from 'react';
33
import { clsx } from 'clsx';
44
import { customClassSwitcher } from '~/core';
55

6-
const RENDER_AS_ENUMS = [
7-
{
8-
label: 'H1',
9-
tag: 'h1'
10-
},
11-
{
12-
label: 'H2',
13-
tag: 'h2'
14-
},
15-
{
16-
label: 'H3',
17-
tag: 'h3'
18-
},
19-
{
20-
label: 'H4',
21-
tag: 'h4'
22-
},
23-
{
24-
label: 'H5',
25-
tag: 'h5'
26-
},
27-
{
28-
label: 'H6',
29-
tag: 'h6'
30-
}
31-
];
6+
export type HeadingTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
327

8+
/**
9+
* Heading component that renders HTML heading elements (h1-h6)
10+
* with customizable styling.
11+
*/
3312
export type HeadingProps = {
34-
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
13+
/** HTML heading tag to render */
14+
as?: HeadingTag;
15+
/** Custom root class for specialized styling */
3516
customRootClass?: string;
17+
/** Additional class names to apply */
3618
className?: string;
19+
/** Content of the heading */
3720
children?: React.ReactNode;
38-
props?: any;
39-
};
21+
} & React.HTMLAttributes<HTMLHeadingElement>;
4022

41-
const Heading = ({ children, as = 'h1', customRootClass = '', className = '', ...props }: HeadingProps) => {
42-
const rootClass = customClassSwitcher(customRootClass, as || 'h1');
23+
/**
24+
* Renders a heading element with customizable tag and styling
25+
*/
26+
const Heading = ({
27+
children,
28+
as = 'h1',
29+
customRootClass = '',
30+
className = '',
31+
...props
32+
}: HeadingProps) => {
33+
const rootClass = customClassSwitcher(customRootClass, as);
4334

44-
const tag = RENDER_AS_ENUMS.find((item) => item.tag === as) ? as : 'h1';
45-
return React.createElement(tag, { className: clsx(rootClass, className), ...props }, children);
35+
// Check if the heading tag is valid
36+
if (!['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(as)) {
37+
as = 'h1';
38+
}
39+
40+
return React.createElement(as, {
41+
className: clsx(rootClass, className),
42+
...props
43+
}, children);
4644
};
45+
4746
Heading.displayName = 'Heading';
4847

4948
export default Heading;

styles/themes/components/heading.scss

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,39 @@
22
.rad-ui-h1{
33
font-weight: bold;
44
font-size: 60px;
5-
letter-spacing: -3.5px;
5+
letter-spacing: -3px;
66
line-height:72px;
77
}
88

99
.rad-ui-h2{
1010
font-weight: bold;
1111
font-size: 35px;
12-
letter-spacing: -3px;
12+
letter-spacing: -1px;
1313
line-height:42px;
1414
}
1515

1616
.rad-ui-h3{
1717
font-weight: bold;
1818
font-size: 28px;
19-
letter-spacing: -2px;
2019
line-height:34px;
2120
}
2221

2322
.rad-ui-h4{
2423
font-weight: bold;
2524
font-size: 24px;
26-
letter-spacing: -1px;
2725
line-height:24px;
2826
}
2927

3028
.rad-ui-h5{
3129
font-weight: bold;
3230
font-size: 20px;
33-
letter-spacing: -0.5px;
31+
letter-spacing: 1px;
3432
line-height:24px;
3533
}
3634

3735
.rad-ui-h6{
3836
font-weight: bold;
3937
font-size: 18px;
4038
line-height:24px;
39+
letter-spacing: 1px;
4140
}

0 commit comments

Comments
 (0)