Skip to content

Commit

Permalink
fix: line number width css should be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 16, 2025
1 parent b10d218 commit 397f25c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 54 deletions.
1 change: 0 additions & 1 deletion site/app/editor-example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { LiveEditor } from './live-editor'

const defaultCode = `\
import { useState } from 'react'
import { highlight } from 'sugar-high'
import { Editor } from 'codice'
const defaultText = 'console.log("hello world")'
Expand Down
98 changes: 50 additions & 48 deletions site/app/live-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,58 +156,60 @@ export function LiveEditor({
return (
<div>
{/* Controls to for displaying the `title`, `controls`, `lineNumbers` */}
<div className="controls-manager">
<ControlButton
id="control-title"
checked={!!title}
propName="title"
content={
<Input
value={title}
onChange={v => { setTitle(v) }}
/>
}
<div className='controls'>
<div className="controls-manager">
<ControlButton
id="control-title"
checked={!!title}
propName="title"
content={
<Input
value={title}
onChange={v => { setTitle(v) }}
/>
}
/>
<ControlButton
id="control-control"
checked={controls}
onChange={setControls}
propName="controls"
/>
<ControlButton
id="control-line-numbers"
checked={lineNumbers}
onChange={setLineNumbers}
propName="lineNumbers"
/>
</div>
<RangeSelector
text="fontSize"
className="range-control"
min={12}
max={24}
step={2}
value={fontSize}
onChange={setFontSize}
/>
<ControlButton
id="control-control"
checked={controls}
onChange={setControls}
propName="controls"
<RangeSelector
text="padding"
className="range-control"
min={1}
max={2}
step={0.1}
value={padding}
onChange={setPadding}
/>
<ControlButton
id="control-line-numbers"
checked={lineNumbers}
onChange={setLineNumbers}
propName="lineNumbers"
<RangeSelector
text="lineNumbersWidth"
className="range-control"
value={lineNumbersWidth}
min={1}
max={2}
step={0.2}
onChange={setLineNumbersWidth}
/>
</div>
<RangeSelector
text="fontSize"
className="range-control"
min={12}
max={24}
step={2}
value={fontSize}
onChange={setFontSize}
/>
<RangeSelector
text="padding"
className="range-control"
min={1}
max={2}
step={0.1}
value={padding}
onChange={setPadding}
/>
<RangeSelector
text="lineNumbersWidth"
className="range-control"
value={lineNumbersWidth}
min={1}
max={2}
step={0.2}
onChange={setLineNumbersWidth}
/>

<div className='editor-layout'>
<span
Expand Down
8 changes: 7 additions & 1 deletion site/app/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ input[type=radio] {
margin: 2rem 0;
border: 1px solid rgba(163, 169, 165, 0.2);
}
.code-example__item code {
font-size: 14px;
}
.code-example__item__title {
margin: 0 0 2rem;
}
Expand Down Expand Up @@ -170,6 +173,9 @@ input[type=radio] {
cursor: pointer;
transform: translateY(-0.25rem);
}
.controls {
margin: 2rem 0 4rem;
}
.controls-manager {
display: flex;
font-size: 14px;
Expand All @@ -192,7 +198,7 @@ input[type=radio] {
}
.editor-layout .copy-image {
position: absolute;
top: 14px;
top: 12px;
right: 16px;
cursor: pointer;
transition: transform 0.2s ease-in-out;
Expand Down
1 change: 0 additions & 1 deletion src/code/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const lineNumbersCss = (id: string) => `\
content: counter(codice-code-line-number);
display: inline-block;
min-width: calc(2rem - 6px);
width: var(--codice-code-line-number-width);
margin-left: calc(var(--codice-code-line-number-width) * -1);
margin-right: 16px;
text-align: right;
Expand Down
3 changes: 0 additions & 3 deletions src/editor/editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ describe('Code', () => {
content: counter(codice-code-line-number);
display: inline-block;
min-width: calc(2rem - 6px);
width: var(--codice-code-line-number-width);
margin-left: calc(var(--codice-code-line-number-width) * -1);
margin-right: 16px;
text-align: right;
Expand Down Expand Up @@ -343,7 +342,6 @@ describe('Code', () => {
content: counter(codice-code-line-number);
display: inline-block;
min-width: calc(2rem - 6px);
width: var(--codice-code-line-number-width);
margin-left: calc(var(--codice-code-line-number-width) * -1);
margin-right: 16px;
text-align: right;
Expand Down Expand Up @@ -486,7 +484,6 @@ describe('Code', () => {
content: counter(codice-code-line-number);
display: inline-block;
min-width: calc(2rem - 6px);
width: var(--codice-code-line-number-width);
margin-left: calc(var(--codice-code-line-number-width) * -1);
margin-right: 16px;
text-align: right;
Expand Down

0 comments on commit 397f25c

Please sign in to comment.