Skip to content

Commit 6722a8a

Browse files
authored
fix(codebytes): style tweaks (#33)
* we dont want main * let parent pass in styles * remove iframe prop * allow better overrides * lets try this? * remove mt * remove unused import * min height * attempt to fix axe issues * diff color * please work * forgot hash * cleanup * lets try this * lets try this * please work * holy grail * dev dependency * proper package json * please * revert * revert rest too * hail mary * gah * time to sign off * try this * remove props * allow max width to be overrided
1 parent 457f130 commit 6722a8a

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

packages/codebytes/src/MonacoEditor/theme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const theme = ({
5858
'editorIndentGuide.background': ui.indent.inactive,
5959
'editorIndentGuide.activeBackground': ui.indent.active,
6060
'editorWhitespace.foreground': syntax.comment,
61+
'editorLineNumber.foreground': '#9FA2AC',
6162
},
6263
});
6364

packages/codebytes/src/codeByteEditor.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Box, IconButton } from '@codecademy/gamut';
22
import { FaviconIcon } from '@codecademy/gamut-icons';
3-
import { Background, states, system } from '@codecademy/gamut-styles';
3+
import { Background, system } from '@codecademy/gamut-styles';
44
import { StyleProps } from '@codecademy/variance';
55
import styled from '@emotion/styled';
66
import React, { useEffect, useState } from 'react';
@@ -12,38 +12,28 @@ import { LanguageSelection } from './languageSelection';
1212
import { trackUserImpression } from './libs/eventTracking';
1313
import { CodeByteEditorProps } from './types';
1414

15-
const editorStates = states({
16-
isIFrame: { height: '100vh', width: '100%' },
17-
});
18-
1915
const editorBaseStyles = system.css({
2016
border: 1,
2117
borderColor: 'gray-900',
2218
display: 'flex',
2319
flexDirection: 'column',
24-
height: '25rem',
25-
width: '43rem',
26-
overflow: 'hidden',
20+
minHeight: '25rem',
2721
});
28-
export interface EditorStyleProps
29-
extends StyleProps<typeof editorBaseStyles>,
30-
StyleProps<typeof editorStates> {}
3122

32-
const EditorContainer = styled(Background)<EditorStyleProps>(
33-
editorBaseStyles,
34-
editorStates
23+
const EditorContainer = styled(Background)<StyleProps<typeof editorBaseStyles>>(
24+
editorBaseStyles
3525
);
3626

3727
export const CodeByteEditor: React.FC<CodeByteEditorProps> = ({
3828
text: initialText,
3929
language: initialLanguage,
4030
hideCopyButton = false,
41-
isIFrame = false,
4231
snippetsBaseUrl,
4332
onEdit,
4433
onLanguageChange,
4534
onCopy,
4635
trackingData,
36+
...rest
4737
}) => {
4838
const getInitialText = () => {
4939
if (initialText !== undefined) return initialText;
@@ -70,7 +60,7 @@ export const CodeByteEditor: React.FC<CodeByteEditorProps> = ({
7060
}, []);
7161

7262
return (
73-
<EditorContainer bg="black" as="main" isIFrame={isIFrame}>
63+
<EditorContainer bg="black" maxWidth="43rem" {...rest}>
7464
<Box borderBottom={1} borderColor="gray-900" py={4} pl={8}>
7565
<IconButton
7666
icon={FaviconIcon}

packages/codebytes/src/drawers.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ const RightDrawerIcon = LeftDrawerIcon.withComponent(ArrowChevronRightIcon);
1717

1818
const Drawer = styled(FlexBox)<{ open?: boolean; hideOnClose?: boolean }>`
1919
position: relative;
20+
// A hidden overflowing element causes accessibility errors
21+
// The background of the overflowing element causes triggers color contrast errors
22+
& .lines-content {
23+
height: 100% !important;
24+
}
2025
${({ open, hideOnClose }) => `
2126
flex-basis: ${open ? '100%' : '0%'};
2227
visibility: ${!open && hideOnClose ? 'hidden' : 'visible'};
@@ -120,6 +125,8 @@ export const Drawers: React.FC<DrawersProps> = ({ leftChild, rightChild }) => {
120125
<Drawer
121126
hideOnClose
122127
id="output-drawer"
128+
aria-labelledby="output-drawer-label"
129+
role="region"
123130
open={!isLeftOpen}
124131
overflow="hidden"
125132
>

packages/codebytes/src/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
import { BackgroundProps } from '@codecademy/gamut-styles';
12
import { UserClickData } from '@codecademy/tracking';
23

34
import { LanguageOption } from './consts';
45

56
export interface CodebytesChangeHandler {
67
(text: string, language: LanguageOption): void;
78
}
8-
export interface CodeByteEditorProps {
9+
export interface CodeByteEditorProps
10+
extends Omit<BackgroundProps, 'onCopy' | 'bg'> {
911
text?: string;
1012
language?: LanguageOption;
1113
hideCopyButton?: boolean;
1214
onCopy?: CodebytesChangeHandler;
13-
isIFrame?: boolean;
1415
snippetsBaseUrl?: string;
1516
onEdit?: CodebytesChangeHandler;
1617
onLanguageChange?: CodebytesChangeHandler;

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13438,9 +13438,9 @@ [email protected]:
1343813438
loader-utils "^1.2.3"
1343913439

1344013440
"monaco-editor@>= 0.25.0 < 1":
13441-
version "0.31.1"
13442-
resolved "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.31.1.tgz#67f597b3e45679d1f551237e12a3a42c4438b97b"
13443-
integrity sha512-FYPwxGZAeP6mRRyrr5XTGHD9gRXVjy7GUzF4IPChnyt3fS5WrNxIkS8DNujWf6EQy0Zlzpxw8oTVE+mWI2/D1Q==
13441+
version "0.32.0"
13442+
resolved "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.32.0.tgz#653764356aca40a0bf3807d150b01e0f1a604b96"
13443+
integrity sha512-r3xvo6XMA/fg3SuVJb+NMxf+fXHO8GPIOLoPFRO2LIf7GbqfV9W7FdddqT9ze+bCtnLd+s4IScnOGCgDQDg4BQ==
1344413444

1344513445
moo@^0.5.0:
1344613446
version "0.5.1"

0 commit comments

Comments
 (0)