Skip to content

Commit 0bf4279

Browse files
committed
fix: Fixes borders, dark mode highlight, and actions padding style issues
1 parent f3e1063 commit 0bf4279

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

pages/code-view/simple.page.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
import { SpaceBetween } from "@cloudscape-design/components";
5+
46
import { CodeView } from "../../lib/components";
57
import { ScreenshotArea } from "../screenshot-area";
8+
69
export default function CodeViewPage() {
710
return (
811
<ScreenshotArea>
912
<h1>Code View</h1>
10-
<CodeView content={"Hello World"} />
11-
<CodeView
12-
content={`public class HelloWorld {\n public static void main(String[] args) {\n System.out.println("Hello, World!");\n }\n}`}
13-
/>
13+
<SpaceBetween size="s">
14+
<CodeView content={"Hello World"} />
15+
<CodeView
16+
content={`public class HelloWorld {\n public static void main(String[] args) {\n System.out.println("Hello, World!");\n }\n}`}
17+
/>
18+
</SpaceBetween>
1419
</ScreenshotArea>
1520
);
1621
}

src/code-view/internal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export function InternalCodeView({
4343
...props
4444
}: InternalCodeViewProps) {
4545
const baseProps = getBaseProps(props);
46-
const preRef = useRef<HTMLPreElement>(null);
47-
const darkMode = useCurrentMode(preRef) === "dark";
46+
const containerRef = useRef<HTMLDivElement>(null);
47+
const darkMode = useCurrentMode(containerRef) === "dark";
4848

4949
const regionProps = ariaLabel || ariaLabelledby ? { role: "region" } : {};
5050

@@ -54,6 +54,8 @@ export function InternalCodeView({
5454
const codeElementWrapper: ReactElement = createElement(Fragment, null, code);
5555
const codeElement = Children.only(codeElementWrapper.props.children);
5656

57+
console.log("ACE_CLASSES", ACE_CLASSES.dark, ACE_CLASSES.light);
58+
5759
return (
5860
<div
5961
className={clsx(darkMode ? ACE_CLASSES.dark : ACE_CLASSES.light, styles.root)}
@@ -64,7 +66,7 @@ export function InternalCodeView({
6466
dir="ltr"
6567
ref={__internalRootRef}
6668
>
67-
<div className={styles["scroll-container"]}>
69+
<div className={styles["scroll-container"]} ref={containerRef}>
6870
<table
6971
role="presentation"
7072
className={clsx(

src/code-view/styles.scss

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ $color-background-code-view-dark: #282c34;
1010

1111
.root {
1212
position: relative;
13+
border-start-start-radius: cs.$border-radius-tiles;
14+
border-start-end-radius: cs.$border-radius-tiles;
15+
border-end-start-radius: cs.$border-radius-tiles;
16+
border-end-end-radius: cs.$border-radius-tiles;
17+
1318
background-color: $color-background-code-view-light;
1419
:global(.awsui-dark-mode) &,
1520
:global(.awsui-polaris-dark-mode) & {
@@ -22,18 +27,15 @@ $color-background-code-view-dark: #282c34;
2227
}
2328

2429
.code-table {
25-
border-start-start-radius: cs.$border-radius-tiles;
26-
border-start-end-radius: cs.$border-radius-tiles;
27-
border-end-start-radius: cs.$border-radius-tiles;
28-
border-end-end-radius: cs.$border-radius-tiles;
2930
padding-block-start: cs.$space-static-xs;
3031
padding-block-end: cs.$space-static-xs;
3132
table-layout: auto;
32-
width: 100%;
33+
inline-size: 100%;
3334
border-spacing: 0;
3435

3536
&-with-actions {
36-
min-height: calc(2 * cs.$space-scaled-xs + cs.$space-scaled-xxl);
37+
min-block-size: calc(2 * cs.$space-scaled-xs + cs.$space-scaled-xxl);
38+
padding-inline-end: calc(2 * var(--space-static-xxxl-qj5g91, 40px));
3739
}
3840
}
3941

@@ -42,19 +44,14 @@ $color-background-code-view-dark: #282c34;
4244
}
4345

4446
.line-number {
45-
border-right-color: cs.$color-border-divider-default;
46-
background-color: $color-background-code-view-light;
47+
border-inline-end-color: cs.$color-border-divider-default;
4748
vertical-align: text-top;
4849
position: sticky;
49-
left: 0;
50-
border-right-width: 1px;
51-
border-right-style: solid;
52-
padding-left: cs.$space-static-xs;
53-
padding-right: cs.$space-static-xs;
54-
:global(.awsui-dark-mode) &,
55-
:global(.awsui-polaris-dark-mode) & {
56-
background-color: $color-background-code-view-dark;
57-
}
50+
inset-inline-start: 0;
51+
border-inline-end-width: 1px;
52+
border-inline-end-style: solid;
53+
padding-inline-start: cs.$space-static-xs;
54+
padding-inline-end: cs.$space-static-xs;
5855
}
5956

6057
.unselectable {
@@ -63,8 +60,8 @@ $color-background-code-view-dark: #282c34;
6360
}
6461

6562
.code-line {
66-
padding-left: cs.$space-static-xs;
67-
padding-right: cs.$space-static-xs;
63+
padding-inline-start: cs.$space-static-xs;
64+
padding-inline-end: cs.$space-static-xs;
6865
&-wrap {
6966
white-space: pre-wrap;
7067
word-break: break-word;

0 commit comments

Comments
 (0)