Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.5.3 #106

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notios",
"version": "0.5.2",
"version": "0.5.3",
"type": "module",
"description": "",
"keywords": [
Expand Down Expand Up @@ -40,13 +40,13 @@
"commander": "^12.1.0",
"cross-spawn": "7.0.3",
"ink": "^5.0.1",
"ink-divider": "3.0.0",
"node-ipc": "10.1.0",
"npm-run-all": "4.1.5",
"pidtree": "^0.5.0",
"react": "^18.3.1",
"source-map-support": "^0.5.21",
"string-length": "^5.0.1",
"string-width": "^7.2.0",
"wcwidth": "^1.0.1",
"xdg-portable": "10.6.0"
},
Expand Down
20 changes: 3 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 29 additions & 17 deletions src/components/full_divider.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
import type { FC } from 'react';
import React, { useEffect, useState } from 'react';
import React from 'react';
import BoxWithSize from './box_with_size';
import { Box, Text } from 'ink';
import stringWidth from 'string-width';

export interface FullDividerProps {
title?: string;
dividerChar?: string;
dividerColor?: string;
}
const FullDivider: FC<FullDividerProps> = ({ title, dividerChar, dividerColor }) => {
const [Divider, setDivider] = useState<FC<any>>();

useEffect(() => {
import('ink-divider').then(setDivider);
}, []);
const paddingChar = ' ';

const FullDivider: FC<{ title?: string; dividerChar?: string; dividerColor?: string }> = ({
title,
dividerChar = '-',
dividerColor,
}) => {
return (
<BoxWithSize>
{({ width }) =>
Divider && (
<Divider title={title} dividerChar={dividerChar} dividerColor={dividerColor} width={Math.max(width - 5, 1)} />
)
}
{(size) => {
const width = Math.max(size.width - 5, 1);
const titleString = title ? `${paddingChar}${title}${paddingChar}` : '';
const titleWidth = stringWidth(titleString);
const dividerWidth = (width - titleWidth) / 2;
const numberOfCharsPerSide = dividerWidth / stringWidth(dividerChar);
const dividerSideString = dividerChar.repeat(numberOfCharsPerSide);

return (
<Box flexDirection="row">
<Text>
{paddingChar}
<Text color={dividerColor}>{dividerSideString}</Text>
<Text color="#fff">{titleString}</Text>
<Text color={dividerColor}>{dividerSideString}</Text>
{paddingChar}
</Text>
</Box>
);
}}
</BoxWithSize>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
declare module 'ink-divider';
declare module 'npm-run-all/*';
Loading