File size: 3,208 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
import type { VersionInfo } from '../../../../server/dev/parse-version-info'
import { getStaleness } from '../../../shared/version-staleness'
import { cx } from '../../utils/cx'
import { EclipseIcon } from '../../icons/eclipse'
export function VersionStalenessInfo({
versionInfo,
bundlerName,
}: {
versionInfo: VersionInfo
// Passed from parent for easier handling in Storybook.
bundlerName: 'Webpack' | 'Turbopack' | 'Rspack'
}) {
const { staleness } = versionInfo
let { text, indicatorClass, title } = getStaleness(versionInfo)
const isTurbopack = bundlerName === 'Turbopack'
const shouldBeLink = staleness.startsWith('stale')
if (shouldBeLink) {
return (
<a
className="nextjs-container-build-error-version-status dialog-exclude-closing-from-outside-click"
target="_blank"
rel="noopener noreferrer"
href="https://nextjs.org/docs/messages/version-staleness"
>
<EclipseIcon
className={cx('version-staleness-indicator', indicatorClass)}
/>
<span data-nextjs-version-checker title={title}>
{text}
</span>
<span className={cx(isTurbopack && 'turbopack-text')}>
{bundlerName}
</span>
</a>
)
}
return (
<span className="nextjs-container-build-error-version-status dialog-exclude-closing-from-outside-click">
<EclipseIcon
className={cx('version-staleness-indicator', indicatorClass)}
/>
<span data-nextjs-version-checker title={title}>
{text}
</span>
<span className={cx(isTurbopack && 'turbopack-text')}>{bundlerName}</span>
</span>
)
}
export const styles = `
.nextjs-container-build-error-version-status {
display: flex;
justify-content: center;
align-items: center;
gap: 4px;
height: var(--size-26);
padding: 6px 8px 6px 6px;
background: var(--color-background-100);
background-clip: padding-box;
border: 1px solid var(--color-gray-alpha-400);
box-shadow: var(--shadow-small);
border-radius: var(--rounded-full);
color: var(--color-gray-900);
font-size: var(--size-12);
font-weight: 500;
line-height: var(--size-16);
}
a.nextjs-container-build-error-version-status {
text-decoration: none;
color: var(--color-gray-900);
&:hover {
background: var(--color-gray-100);
}
&:focus {
outline: var(--focus-ring);
}
}
.version-staleness-indicator.fresh {
fill: var(--color-green-800);
stroke: var(--color-green-300);
}
.version-staleness-indicator.stale {
fill: var(--color-amber-800);
stroke: var(--color-amber-300);
}
.version-staleness-indicator.outdated {
fill: var(--color-red-800);
stroke: var(--color-red-300);
}
.version-staleness-indicator.unknown {
fill: var(--color-gray-800);
stroke: var(--color-gray-300);
}
.nextjs-container-build-error-version-status > .turbopack-text {
background: linear-gradient(
to right,
var(--color-turbopack-text-red) 0%,
var(--color-turbopack-text-blue) 100%
);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
`
|