Skip to content

Commit

Permalink
Release/0.0.26 (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
kotAPI authored Dec 25, 2024
1 parent a5d0d43 commit 91ba422
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 39 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@radui/ui",
"version": "0.0.25",
"version": "0.0.26",
"description": "",
"main": "dist",
"type": "module",
Expand All @@ -9,6 +9,7 @@
"./themes/tailwind-presets/default.js": "./dist/themes/tailwind-presets/default.js",
"./Accordion": "./dist/components/Accordion.js",
"./AlertDialog": "./dist/components/AlertDialog.js",
"./AspectRatio": "./dist/components/AspectRatio.js",
"./Avatar": "./dist/components/Avatar.js",
"./AvatarGroup": "./dist/components/AvatarGroup.js",
"./Badge": "./dist/components/Badge.js",
Expand All @@ -20,6 +21,7 @@
"./Collapsible": "./dist/components/Collapsible.js",
"./Em": "./dist/components/Em.js",
"./Heading": "./dist/components/Heading.js",
"./HoverCard": "./dist/components/HoverCard.js",
"./Kbd": "./dist/components/Kbd.js",
"./Link": "./dist/components/Link.js",
"./Progress": "./dist/components/Progress.js",
Expand All @@ -35,7 +37,8 @@
"./TextArea": "./dist/components/TextArea.js",
"./Toggle": "./dist/components/Toggle.js",
"./ToggleGroup": "./dist/components/ToggleGroup.js",
"./Tooltip": "./dist/components/Tooltip.js"
"./Tooltip": "./dist/components/Tooltip.js",
"./VisuallyHidden": "./dist/components/VisuallyHidden.js"
},
"scripts": {
"test": "jest",
Expand Down
13 changes: 6 additions & 7 deletions src/components/ui/AspectRatio/AspectRatio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ export type AspectRatioProps = {
props: Record<string, any>[];
}

const AspectRatio = ({ children, customRootClass, className, ratio="1", ...props }: AspectRatioProps) => {

if (isNaN(Number(ratio)) && !ratio.match(/^(\d+)\/(\d+)$/)) ratio = "1"
if (Number(ratio) <= 0) ratio = "1"
const AspectRatio = ({ children, customRootClass, className, ratio = '1', ...props }: AspectRatioProps) => {
if (isNaN(Number(ratio)) && !ratio.match(/^(\d+)\/(\d+)$/)) ratio = '1';
if (Number(ratio) <= 0) ratio = '1';

const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
return <div style={{aspectRatio:ratio}} className={clsx(rootClass, className)} {...props}>{children} </div>
}
return <div style={{ aspectRatio: ratio }} className={clsx(rootClass, className)} {...props}>{children} </div>;
};
AspectRatio.displayName = COMPONENT_NAME;

export default AspectRatio;
export default AspectRatio;
14 changes: 7 additions & 7 deletions src/components/ui/AspectRatio/stories/AspectRatio.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ export default {
<AspectRatio {...args} >
<img
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
className="Image"
src="https://images.pexels.com/photos/346529/pexels-photo-346529.jpeg?cs=srgb&dl=pexels-bri-schneiter-28802-346529.jpg&fm=jpg"
alt="Landscape photograph"
/>
</AspectRatio>
className="Image"
src="https://images.pexels.com/photos/346529/pexels-photo-346529.jpeg?cs=srgb&dl=pexels-bri-schneiter-28802-346529.jpg&fm=jpg"
alt="Landscape photograph"
/>
</AspectRatio>
</SandboxEditor>
};

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Default = {
args: {
className:"",
ratio: "16/9"
className: '',
ratio: '16/9'
}
};
6 changes: 2 additions & 4 deletions src/components/ui/AspectRatio/tests/AspectRatio.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('AspectRatio', () => {
});

test('applies custom classes correctly', () => {
render(<AspectRatio className="additional-class">Content</AspectRatio>);
render(<AspectRatio className="additional-class">Content</AspectRatio>);
const divElement = screen.getByText('Content');
expect(divElement).toHaveClass('additional-class');
});
Expand Down Expand Up @@ -38,6 +38,4 @@ describe('AspectRatio', () => {
render(<AspectRatio ratio="-5">Content</AspectRatio>);
expect(screen.getByText('Content').style.aspectRatio).toBe('1');
});


});
});
4 changes: 2 additions & 2 deletions src/components/ui/Code/Code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export type CodeProps= {
customRootClass?: string;
}

const Code = ({ children, customRootClass='' }: CodeProps) => {
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME)
const Code = ({ children, customRootClass = '' }: CodeProps) => {
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);

return <code className={clsx(rootClass)}>
{children}
Expand Down
8 changes: 3 additions & 5 deletions src/components/ui/VisuallyHidden/VisuallyHidden.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ export type VisuallyHiddenProps = {
}

const VisuallyHidden = ({ children, customRootClass, className, ...props }: VisuallyHiddenProps) => {

const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
return <Primitive.div className={clsx(rootClass, className)} {...props}>{children}</Primitive.div>

}
return <Primitive.div className={clsx(rootClass, className)} {...props}>{children}</Primitive.div>;
};
VisuallyHidden.displayName = COMPONENT_NAME;

export default VisuallyHidden;
export default VisuallyHidden;
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@ export default {
component: VisuallyHidden,
render: (args: VisuallyHiddenProps) => <SandboxEditor>
<VisuallyHidden {...args}>
{args.children}
</VisuallyHidden>
{args.children}
</VisuallyHidden>
</SandboxEditor>
};


// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Default = {
args: {
className:"",
children: "This is a visually hidden text",
className: '',
children: 'This is a visually hidden text'
}
};

export const WithAsChild = {
args: {
asChild: true,
children: <span>This is a visually hidden text </span>,
asChild: true,
children: <span>This is a visually hidden text </span>
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import VisuallyHidden from '../VisuallyHidden';


describe('VisuallyHidden Component', () => {
test('renders VisuallyHidden component', () => {
render(<VisuallyHidden>Visually Hidden</VisuallyHidden>);
Expand All @@ -22,6 +21,5 @@ describe('VisuallyHidden Component', () => {
test('renders VisuallyHidden component with asChild prop as span', () => {
render(<VisuallyHidden asChild><span>Visually Hidden</span></VisuallyHidden>);
expect(screen.getByText('Visually Hidden').tagName).toBe('SPAN');

});
})
});

0 comments on commit 91ba422

Please sign in to comment.