Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
feat(features/cards): show language name rotated on the left side
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeysova committed Oct 25, 2019
1 parent ebe1491 commit ccfe6e2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
54 changes: 32 additions & 22 deletions src/lib/rich-text/extensions/code-plugin/code-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,44 @@ export class CodeBlock extends React.Component {
)

const languageComponent = editor.readOnly ? (
<p style={{ textAlign: "right", paddingRight: "10px" }}>{language}</p>
<LanguageName>{language}</LanguageName>
) : (
<MultiSelect
value={selectedValueForSelect}
onChange={({ value }) => this.onChange(value)}
options={optionsForSelect}
/>
<div
contentEditable={false}
style={{
position: "absolute",
top: "5px",
right: "5px",
width: "200px",
}}
>
<MultiSelect
value={selectedValueForSelect}
onChange={({ value }) => this.onChange(value)}
options={optionsForSelect}
/>
</div>
)

return (
<div className={className} style={{ position: "relative" }}>
<pre className={`language-${language}`}>
<code {...attributes} className={`language-${language}`}>
{children}
</code>
</pre>
<div
contentEditable={false}
style={{
position: "absolute",
top: "5px",
right: "5px",
width: "200px",
}}
>
{languageComponent}
<div style={{ position: "relative" }}>
<div className={className} style={{ position: "relative" }}>
<pre className={`language-${language}`}>
<code {...attributes} className={`language-${language}`}>
{children}
</code>
</pre>
</div>
{languageComponent}
</div>
)
}
}

const LanguageName = styled.div`
position: absolute;
left: 0rem;
top: 0.5rem;
writing-mode: vertical-rl;
transform: rotate(180deg);
`
2 changes: 1 addition & 1 deletion src/lib/rich-text/rich-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class RichEditor extends React.Component {
readOnly={readOnly}
{...HotKeys(configCodePlugin)}
style={{
minHeight: "300px",
minHeight: "50px",
}}
value={value}
onChange={this.onChange}
Expand Down
2 changes: 2 additions & 0 deletions src/ui/themes/prismcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const prismcssDark = css`
margin: 0.5em 0;
overflow: auto;
padding: 2rem;
padding-left: 3rem;
${({ theme }) => theme.embed.canvas};
background-color: #171717;
}
Expand Down Expand Up @@ -226,6 +227,7 @@ export const prismcssLight = css`
margin: 0.5em 0;
overflow: auto;
padding: 2rem;
padding-left: 3rem;
${({ theme }) => theme.embed.canvas}
}
Expand Down

0 comments on commit ccfe6e2

Please sign in to comment.