Skip to content

Commit

Permalink
Merge pull request #336 from WestpacGEL/322-gel-site-code-tab-header
Browse files Browse the repository at this point in the history
322 gel site code tab header
  • Loading branch information
samithaf authored Nov 22, 2023
2 parents 48d25c4 + 0fee9e0 commit e36f39d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useMemo } from 'react';
import { ComponentPropsTable } from '@/components/component-props-table';
import { Code } from '@/components/content-blocks/typography';
import { Heading } from '@/components/document-renderer';
import { pascalToKebab } from '@/utils/format-string';

import { DOCUMENT_RENDERERS } from '../document-renderer';
import { TableOfContents } from '../intro/components';
Expand All @@ -33,7 +34,7 @@ export function CodeContent({ content = [], westpacUIInfo, componentProps, subCo
<Container>
<Grid>
<Item span={{ initial: 12, sm: 7 }}>
<table className="table w-full bg-[#f2f8fc] text-info">
<table className="typography-body-11 table w-full bg-[#f2f8fc] text-info">
<tbody>
<tr>
<th className="w-10 border-y border-gel-icon p-3 text-left font-semibold">Version</th>
Expand All @@ -45,7 +46,7 @@ export function CodeContent({ content = [], westpacUIInfo, componentProps, subCo
<Button
tag="a"
size="small"
className="pl-0"
className="p-0 leading-none"
look="link"
target="_blank"
href={westpacUIInfo?.changelog || '#'}
Expand All @@ -63,10 +64,14 @@ export function CodeContent({ content = [], westpacUIInfo, componentProps, subCo
<Code>npm install @westpac/ui</Code>
</td>
</tr>
<tr>
<th className="w-10 border-y border-gel-icon p-3 text-left font-semibold">Requires</th>
<td className="border-y border-gel-icon p-3">react@18</td>
</tr>
{componentProps && (
<tr>
<th className="w-10 border-y border-gel-icon p-3 text-left font-semibold">Usage</th>
<td className="border-y border-gel-icon p-3 text-black">
<Code>{`import { ... } from @westpac/ui/${pascalToKebab(componentProps.displayName)}`}</Code>
</td>
</tr>
)}
</tbody>
</table>
</Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function Link({ href, children }: { children?: React.ReactNode; href?: string })
);

return (
<a href={href} className="hover:underline" onClick={handleClick}>
<a href={href} className="ml-1 hover:underline block" onClick={handleClick}>
{children}
</a>
);
Expand Down
4 changes: 4 additions & 0 deletions apps/site/src/utils/format-string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function pascalToKebab(str: string) {
// Insert a hyphen before each capital letter, then convert to lowercase
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
}

0 comments on commit e36f39d

Please sign in to comment.