@atlaskit/code 14.4.5 → 14.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/code
2
2
 
3
+ ## 14.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b0f6dd0bc35`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b0f6dd0bc35) - Updated to use typography tokens. There is no expected behaviour or visual change.
8
+
3
9
  ## 14.4.5
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ import { CodeBlock } from '../src';
4
+
5
+ import { hundredLineExample } from './source-code-examples/100-line-example';
6
+
7
+ export default () => <CodeBlock text={hundredLineExample} language="tsx" />;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ import { CodeBlock } from '../src';
4
+
5
+ import { thousandLineExample } from './source-code-examples/1000-line-example';
6
+
7
+ export default () => <CodeBlock text={thousandLineExample} language="tsx" />;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ import { CodeBlock } from '../src';
4
+
5
+ import { hugeFileExample } from './source-code-examples/4458-line-example';
6
+
7
+ export default () => <CodeBlock text={hugeFileExample} language="javascript" />;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ import { CodeBlock } from '../src';
4
+
5
+ import { fiveHundredLineExample } from './source-code-examples/500-line-example';
6
+
7
+ export default () => <CodeBlock text={fiveHundredLineExample} language="tsx" />;
@@ -2,6 +2,6 @@ import React from 'react';
2
2
 
3
3
  import { CodeBlock } from '../src';
4
4
 
5
- import { text } from './code-block-jsx';
5
+ import { text } from './code-block-syntax-highlighting';
6
6
 
7
7
  export default () => <CodeBlock text={text} />;
File without changes
@@ -0,0 +1,101 @@
1
+ // eslint-disable-file
2
+ export const hundredLineExample = `/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
3
+ /** @jsx jsx */
4
+ import React, { forwardRef, useMemo } from 'react';
5
+
6
+ import { css, jsx } from '@emotion/react';
7
+
8
+ import { UNSAFE_Box as Box, UNSAFE_BoxProps as BoxProps, UNSAFE_Inline as Inline, UNSAFE_Text as Text, UNSAFE_TextProps as TextProps, } from '@atlaskit/ds-explorations';
9
+ import { N0, N500, N700, R400, Y300 } from '@atlaskit/theme/colors';
10
+ import { token } from '@atlaskit/tokens';
11
+
12
+ // Applies styles to nested links within banner messages.
13
+ const nestedLinkStyles = css({
14
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
15
+ 'a, a:visited, a:hover, a:focus, a:active': {
16
+ color: 'currentColor',
17
+ textDecoration: 'underline',
18
+ },
19
+ });
20
+
21
+ const backgroundColors: Record<Appearance, BoxProps['backgroundColor']> = {
22
+ warning: 'warning.bold',
23
+ error: 'danger.bold',
24
+ announcement: 'neutral.bold',
25
+ };
26
+
27
+ const tokenBackgroundColors: Record<Appearance, string> = {
28
+ warning: token('color.background.warning.bold', Y300),
29
+ error: token('color.background.danger.bold', R400),
30
+ announcement: token('color.background.neutral.bold', N500),
31
+ };
32
+
33
+ const textColors: Record<Appearance, TextProps['color']> = {
34
+ warning: 'warning.inverse',
35
+ error: 'inverse',
36
+ announcement: 'inverse',
37
+ };
38
+
39
+ const tokenTextColors: Record<Appearance, string> = {
40
+ warning: token('color.text.warning.inverse', N700),
41
+ error: token('color.text.inverse', N0),
42
+ announcement: token('color.text.inverse', N0),
43
+ };
44
+
45
+ type Appearance = 'warning' | 'error' | 'announcement';
46
+
47
+ interface BannerProps {
48
+ appearance?: Appearance;
49
+ children?: React.ReactNode;
50
+ icon?: React.ReactElement;
51
+ testId?: string;
52
+ }
53
+
54
+ const Banner = forwardRef<HTMLDivElement, BannerProps>(
55
+ ({ appearance = 'warning', children, icon, testId }, ref) => {
56
+ const appearanceType =
57
+ appearance in backgroundColors ? appearance : 'warning';
58
+
59
+ const accessibilityProps = useMemo(() => {
60
+ const baseProps = {
61
+ role: 'alert',
62
+ };
63
+
64
+ if (appearance === 'announcement') {
65
+ return {
66
+ ...baseProps,
67
+ 'aria-label': 'announcement',
68
+ tabIndex: 0,
69
+ role: 'region',
70
+ };
71
+ }
72
+
73
+ return baseProps;
74
+ }, [appearance]);
75
+
76
+ return (
77
+ <Box display="block" backgroundColor={backgroundColors[appearanceType]} paddingInline="scale.150" overflow="hidden" testId={testId} ref={ref} {...accessibilityProps} UNSAFE_style={{ paddingBlock: '14px', maxHeight: '52px', }} css={nestedLinkStyles} >
78
+ <Inline gap="scale.050" alignItems="center" justifyContent="start">
79
+ {icon ? (
80
+ <Box
81
+ as="span"
82
+ display="inline"
83
+ width="scale.300"
84
+ height="scale.300" // This matches Icon's "medium" size, without this the (line-)height is greater than that of the Icon
85
+ UNSAFE_style={{
86
+ fill: tokenBackgroundColors[appearanceType],
87
+ color: tokenTextColors[appearanceType],
88
+ flexShrink: 0,
89
+ }}
90
+ >
91
+ {icon}
92
+ </Box>
93
+ ) : null}
94
+ <Text fontWeight="500" lineHeight="24px" color={textColors[appearanceType]} shouldTruncate> {children} </Text>
95
+ </Inline>
96
+ </Box>
97
+ );
98
+ },
99
+ );
100
+
101
+ export default Banner;`;