Skip to content

Commit

Permalink
chore: improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
okineadev committed Dec 10, 2024
1 parent 14fe192 commit 6f6816d
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"files": {
"ignore": ["*.snap"]
"ignore": ["*.snap", "package.json"]
},
"formatter": {
"enabled": true,
Expand All @@ -16,7 +16,7 @@
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "single",
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "es5",
"semicolons": "asNeeded",
Expand Down
6 changes: 3 additions & 3 deletions examples/advanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Divider from '../src'
*/
const Advanced = () => (
<Divider
title='Title' // Title of the divider.
dividerChar='=' // Character used for the divider line (instead of '-').
dividerColor='red' // Color of the divider (red).
title="Title" // Title of the divider.
dividerChar="=" // Character used for the divider line (instead of '-').
dividerColor="red" // Color of the divider (red).
width={40} // Width of the divider line.
/>
)
Expand Down
6 changes: 3 additions & 3 deletions examples/auto-grow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const lorem = (
*/
render(
<Box
borderStyle='round' // Rounded border style for the Box.
flexDirection='column' // Arranges elements vertically within the Box.
alignSelf='flex-start' // Aligns the Box to the start of the cross axis.
borderStyle="round" // Rounded border style for the Box.
flexDirection="column" // Arranges elements vertically within the Box.
alignSelf="flex-start" // Aligns the Box to the start of the cross axis.
paddingLeft={1} // Left padding of the Box.
paddingRight={1} // Right padding of the Box.
>
Expand Down
2 changes: 1 addition & 1 deletion examples/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import Divider from '../src'
* Basic Divider component example.
* Demonstrates rendering a divider with a title and specified width.
*/
const Basic = () => <Divider title='Title' width={40} /> // Divider with title and width
const Basic = () => <Divider title="Title" width={40} /> // Divider with title and width

render(<Basic />)
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
},
"keywords": ["ink", "ink-component", "ink-divider", "ink-cli"],
"trustedDependencies": ["@biomejs/biome"]
"keywords": [
"ink",
"ink-component",
"ink-divider",
"ink-cli"
],
"trustedDependencies": [
"@biomejs/biome"
]
}
2 changes: 2 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const Divider: React.FC<DividerProps> = ({
/>
)

// If there is no title, return only the divider line
if (!title) {
return (
<Box paddingLeft={padding} paddingRight={padding}>
Expand All @@ -180,6 +181,7 @@ const Divider: React.FC<DividerProps> = ({
)
}

// Otherwise, return the divider line with the title in the middle
return (
<Box
width={width}
Expand Down
35 changes: 13 additions & 22 deletions tests/divider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ test('divider in box with sample text', () => {
)
const { lastFrame } = render(
<Box
borderStyle='round'
flexDirection='column'
alignSelf='flex-start'
borderStyle="round"
flexDirection="column"
alignSelf="flex-start"
paddingLeft={1}
paddingRight={1}
>
{lorem}
<Divider title='Title' />
<Divider title="Title" />
{lorem}
</Box>
)
Expand All @@ -32,7 +32,7 @@ test('divider without title', () => {
})

test('divider with title', () => {
const { lastFrame } = render(<Divider title='Title' />)
const { lastFrame } = render(<Divider title="Title" />)
expect(lastFrame()).toMatchSnapshot()
})

Expand All @@ -47,45 +47,36 @@ test('divider with custom padding', () => {
})

test('divider with title and custom titlePadding', () => {
const { lastFrame } = render(<Divider title='Title' titlePadding={3} />)
const { lastFrame } = render(<Divider title="Title" titlePadding={3} />)
expect(lastFrame()).toMatchSnapshot()
})

test('divider with title and custom titleColor', () => {
const { lastFrame } = render(<Divider title='Title' titleColor='blue' />)
const { lastFrame } = render(<Divider title="Title" titleColor="blue" />)
expect(lastFrame()).toMatchSnapshot()
})

test('divider with custom dividerChar', () => {
const { lastFrame } = render(<Divider dividerChar='=' />)
const { lastFrame } = render(<Divider dividerChar="=" />)
expect(lastFrame()).toMatchSnapshot()
})

test('divider with custom dividerColor', () => {
const { lastFrame } = render(<Divider dividerColor='red' />)
const { lastFrame } = render(<Divider dividerColor="red" />)
expect(lastFrame()).toMatchSnapshot()
})

test('divider with all custom props', () => {
const { lastFrame } = render(
<Divider
title='Custom Title'
title="Custom Title"
width={30}
padding={1}
titlePadding={2}
titleColor='green'
dividerChar='*'
dividerColor='yellow'
titleColor="green"
dividerChar="*"
dividerColor="yellow"
/>
)
expect(lastFrame()).toMatchSnapshot()
})

test('divider with title and other box props (flexGrow, etc.)', () => {
const { lastFrame } = render(
<Box width={50}>
<Divider title='Title' flexGrow={1} />
</Box>
)
expect(lastFrame()).toMatchSnapshot()
})
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"noFallthroughCasesInSwitch": true,

// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": false,

"types": ["@types/react", "bun-types"]
Expand Down

0 comments on commit 6f6816d

Please sign in to comment.