Skip to content
6 changes: 0 additions & 6 deletions apps/site/components/Common/Partners/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,3 @@
grid-cols-[repeat(auto-fill,minmax(240px,1fr))]
gap-4;
}

.tooltip {
@apply p-2
text-neutral-900
dark:text-neutral-200;
}
15 changes: 7 additions & 8 deletions apps/site/components/Common/Partners/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Tooltip from '@node-core/ui-components/Common/Tooltip';
import * as PartnerLogos from '@node-core/ui-components/Icons/PartnerLogos';

import providePartners from '#site/next-data/providers/partners';
Expand Down Expand Up @@ -36,15 +35,15 @@ const renderSmallPartner = (partner: Partner) => {
const Logo = PartnerLogos[partner.id];

return (
<Tooltip
<PartnerButton
aria-label={partner.name}
key={partner.id}
asChild
content={<div className={style.tooltip}>{partner.name}</div>}
Comment thread
ovflowd marked this conversation as resolved.
size="small"
href={partner.href}
data-tooltip={partner.name}
>
<PartnerButton aria-label={partner.name} size="small" href={partner.href}>
<Logo.Favicon />
</PartnerButton>
</Tooltip>
<Logo.Favicon />
</PartnerButton>
Comment thread
ovflowd marked this conversation as resolved.
);
};

Expand Down
8 changes: 2 additions & 6 deletions apps/site/components/withMetaBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ const WithMetaBar: FC = () => {
// Since we cannot show the same number of avatars in Mobile / Tablet
// resolution as we do on desktop and there is overflow, we are adjusting
// the number of avatars manually for the resolutions below
const isMobileResolution = useMediaQuery('(max-width: 890px)');

const isTabletResolution = useMediaQuery(
'(min-width: 890px) and (max-width: 1280px)'
);
const isSmallerThanDesktop = useMediaQuery('(max-width: 1280px)');

return (
<MetaBar
Expand All @@ -55,7 +51,7 @@ const WithMetaBar: FC = () => {
)]: (
<WithAvatarGroup
usernames={usernames}
limit={isMobileResolution ? 7 : isTabletResolution ? 5 : 9}
limit={isSmallerThanDesktop ? 5 : 8}
/>
),
}),
Expand Down
2 changes: 2 additions & 0 deletions apps/site/layouts/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const PostLayout: FC<PropsWithChildren> = ({ children }) => {
<WithNavBar />

<div className={styles.contentLayout}>
<div></div>

<div className={styles.postLayout}>
<main id="main" tabIndex={-1}>
{type === 'vulnerability' && <EOLAlert />}
Expand Down
29 changes: 15 additions & 14 deletions apps/site/layouts/layouts.module.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@reference "../styles/index.css";

.baseLayout {
@apply grid
@apply ml:grid
ml:grid-cols-[1fr]
ml:grid-rows-[auto_1fr_auto]
h-max
min-h-full
w-full
grid-cols-[1fr]
grid-rows-[auto_1fr_auto];
w-full;
}

.centeredLayout {
Expand Down Expand Up @@ -104,7 +104,7 @@
justify-center;

main {
@apply max-w-5xl
@apply max-w-7xl
gap-4
px-4
py-12
Expand Down Expand Up @@ -135,17 +135,19 @@
}

.contentLayout {
@apply max-w-8xl
@apply max-w-10xl
max-ml:m-0
max-ml:block
3xl:grid-cols-[--spacing(80)_1fr_--spacing(80)]
ml:grid-cols-[0_1fr_--spacing(56)]
ml:grid
mx-auto
grid
block
w-full
grid-rows-[1fr]
sm:grid-cols-[1fr_--spacing(52)]
xl:grid-cols-[1fr_--spacing(80)];
xl:grid-cols-[--spacing(56)_1fr_--spacing(64)]
2xl:grid-cols-[--spacing(72)_1fr_--spacing(72)];

> *:nth-child(1) {
> *:nth-child(2) {
@apply bg-gradient-subtle
dark:bg-gradient-subtle-dark
max-ml:border-l-0
Expand All @@ -164,13 +166,12 @@
dark:border-l-neutral-900;

main {
@apply max-w-[660px]
gap-4
@apply gap-4
wrap-anywhere;
}
}

> *:nth-child(2) {
> *:nth-child(3) {
@apply ml:mt-0
ml:max-w-xs
ml:border-l
Expand Down
2 changes: 1 addition & 1 deletion apps/site/next.fetch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const fetchWithRetry = async (
const backoff = Math.max(0, Number(delay) || 0);

const attemptFetch = attempt =>
fetch(url, options).catch(e => {
fetch(url, { ...options, signal: AbortSignal.timeout(30000) }).catch(e => {
Comment thread
ovflowd marked this conversation as resolved.
if (attempt === retries || !isTimeoutError(e)) {
throw e;
}
Comment thread
ovflowd marked this conversation as resolved.
Expand Down
9 changes: 7 additions & 2 deletions packages/rehype-shiki/src/plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ export default async function rehypeShikiji(options) {
const meta = parseMeta(preElement.data?.meta);

// Retrieve the whole <pre> contents as a parsed DOM string
const preElementContents = toString(preElement);
const preElementContents = toString(preElement).replace(/\n$/, '');

// Since we removed the trailing newline, we can easily count the
// amount of lines without worrying about an extra empty line at the end of the code block
const lineCount = preElementContents.split('\n').length;

// Grabs the relevant alias/name of the language
const languageId = codeLanguage.slice(languagePrefix.length);
Expand All @@ -178,7 +182,8 @@ export default async function rehypeShikiji(options) {
// Adds the original language back to the <pre> element
children[0].properties.class = classNames(
children[0].properties.class,
codeLanguage
codeLanguage,
{ 'no-line-numbers': lineCount < 5, 'no-footer': lineCount === 1 }
);

// Replaces the <pre> element with the updated one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
px-4.5
py-2.5
text-center
font-semibold
motion-safe:transition-colors;
font-semibold;

svg {
@apply size-5;
Expand Down Expand Up @@ -124,7 +123,7 @@
after:mx-auto
after:h-px
after:w-2/5
after:bg-gradient-to-r
after:bg-linear-to-r
after:from-green-600/0
after:via-green-600
after:to-green-600/0
Expand Down
27 changes: 23 additions & 4 deletions packages/ui-components/src/Common/BaseCodeBox/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@
[counter-increment:line];
}
}

&[class*='plain-text'] {
Comment thread
avivkeller marked this conversation as resolved.
@apply font-mono;
Comment thread
ovflowd marked this conversation as resolved.
Outdated
}
}

&[class*='no-line-numbers'] > code > [class='line'] {
@apply pl-0;

&:not(:empty:last-child)::after {
@apply content-none
[counter-reset:none];
}
}
}
Comment thread
ovflowd marked this conversation as resolved.

Expand All @@ -62,8 +75,8 @@
justify-between
border-t
border-t-neutral-900
px-4
py-3
px-3
py-2
text-sm
font-medium;

Expand All @@ -72,9 +85,15 @@
}

& > .action {
@apply px-3
py-1.5
@apply px-2.5
py-1
text-xs
font-medium;

> svg {
@apply h-4
w-4;
Comment thread
ovflowd marked this conversation as resolved.
Outdated
}
}
}
}
49 changes: 25 additions & 24 deletions packages/ui-components/src/Common/BaseCodeBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,27 @@ const transformCode = <T extends ReactElement<PropsWithChildren>>(
// being an empty string, so we need to remove it
const lines = content.split('\n');
Comment thread
ovflowd marked this conversation as resolved.

const extraStyle = language.length === 0 ? { fontFamily: 'monospace' } : {};
const extraClasses = classNames({ 'plain-text': language.length === 0 });

return (
<code style={extraStyle}>
{lines
.flatMap((line, lineIndex) => {
const columns = line.split(' ');

return [
<span key={lineIndex} className="line">
{columns.map((column, columnIndex) => (
<Fragment key={columnIndex}>
<span>{column}</span>
{columnIndex < columns.length - 1 && <span> </span>}
</Fragment>
))}
</span>,
// Add a break line so the text content is formatted correctly
// when copying to clipboard
'\n',
];
})
// Here we remove that empty line from before and
// the last flatMap entry which is an `\n`
.slice(0, -2)}
<code className={extraClasses}>
{lines.flatMap((line, lineIndex) => {
const columns = line.split(' ');

return [
<span key={lineIndex} className="line">
{columns.map((column, columnIndex) => (
<Fragment key={columnIndex}>
<span>{column}</span>
{columnIndex < columns.length - 1 && <span> </span>}
</Fragment>
))}
</span>,
// Add a break line so the text content is formatted correctly
// when copying to clipboard
'\n',
];
})}
</code>
);
};
Expand All @@ -89,8 +85,11 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
const containerRef = useRef<HTMLPreElement>(null);

const handleCopy = () => copy(containerRef.current?.textContent);

const ButtonIcon = copied ? DocumentDuplicateIcon : CodeBracketIcon;

const hideFooter = className?.includes('no-footer');

Comment thread
avivkeller marked this conversation as resolved.
return (
<div className={styles.root}>
<pre
Expand All @@ -100,9 +99,11 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
>
{transformCode(children as ReactElement<PropsWithChildren>, language)}
</pre>
{language && (

{!language || hideFooter || (
<div className={styles.footer}>
<span className={styles.language}>{language}</span>

<BaseButton
as={as}
className={styles.action}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
border-neutral-900
bg-neutral-950
px-2
pt-3
pt-2
md:px-4;

.trigger {
Expand Down
18 changes: 17 additions & 1 deletion packages/ui-components/src/Common/DataTag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,24 @@ const symbolMap = {
ctor: 'C',
} as const;

const labelMap = {
event: 'Event',
method: 'Method',
property: 'Property',
class: 'Class',
module: 'Module',
classMethod: 'Class method',
global: 'Global',
ctor: 'Constructor',
} as const;

const DataTag: FC<DataTagProps> = ({ kind, size = 'md' }) => (
<div className={classNames(styles.dataTag, styles[size], styles[kind])}>
<div
className={classNames(styles.dataTag, styles[size], styles[kind])}
data-tooltip={labelMap[kind]}
aria-label={labelMap[kind]}
tabIndex={0}
>
<span>{symbolMap[kind]}</span>
</div>
Comment thread
ovflowd marked this conversation as resolved.
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
p-1.5
text-neutral-900
hover:bg-neutral-100
motion-safe:transition-colors
dark:border-neutral-900
dark:bg-neutral-950
dark:text-neutral-200;

&:hover {
@apply bg-neutral-100
motion-safe:transition-colors
motion-safe:duration-300
dark:bg-neutral-900;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
block
rounded-md
bg-neutral-200
lg:hidden
xl:hidden
dark:bg-neutral-900;

&[open] {
Expand Down Expand Up @@ -49,6 +49,11 @@
dark:hover:text-neutral-500;
}

.codeLink {
@apply font-ibm-plex-mono
font-medium;
}

.depthThree {
@apply pl-2;
}
Expand Down
Loading
Loading