Skip to content

Commit

Permalink
Merge pull request #225 from brainstormforce/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vrundakansara authored Dec 20, 2024
2 parents 1487d61 + 4f86f28 commit 757dbae
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Using Force UI as a dependency in package.json -

```json
"dependencies": {
"@bsf/force-ui": "git+https://github.com/brainstormforce/force-ui#1.3.2"
"@bsf/force-ui": "git+https://github.com/brainstormforce/force-ui#1.3.3"
}
```

Expand All @@ -28,7 +28,7 @@ npm install
Or you can directly run the following command to install the package -

```bash
npm i -S @bsf/force-ui@git+https://github.com/brainstormforce/force-ui.git#1.3.2
npm i -S @bsf/force-ui@git+https://github.com/brainstormforce/force-ui.git#1.3.3
```

<br />
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 1.3.3 - 20th December, 2024
Fixed - React `Each child in a list should have a unique "key" prop` console warning.
Fixed - Toaster content overlapping with the close button.

Version 1.3.2 - 17th December, 2024
Fixed - Adjusted the color of the Switch component label and help text.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bsf/force-ui",
"version": "1.3.2",
"version": "1.3.3",
"description": "Library of components for the BSF project",
"main": "./dist/force-ui.js",
"module": "./dist/force-ui.js",
Expand Down
13 changes: 10 additions & 3 deletions src/components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import React, { forwardRef, type ElementType, type ReactNode } from 'react';
import React, {
forwardRef,
Fragment,
type ElementType,
type ReactNode,
} from 'react';
import { cn } from '@/utilities/functions';

export interface ButtonProps {
Expand Down Expand Up @@ -140,12 +145,14 @@ const Button: React.FunctionComponent<ButtonProps> = forwardRef(
disabled={ disabled }
{ ...rest }
>
{ iconLeft }
<Fragment key="left-icon">{ iconLeft }</Fragment>
{ children ? <span className="px-1">{ children }</span> : null }
{ iconRight }
<Fragment key="right-icon">{ iconRight }</Fragment>
</Tag>
);
}
);

Button.displayName = 'Button';

export default Button;
2 changes: 2 additions & 0 deletions src/components/label/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ const Label = forwardRef(
}
);

Label.displayName = 'Label';

export default Label as <T extends object>(
props: LabelProps & T,
ref: React.Ref<HTMLElement>
Expand Down
10 changes: 9 additions & 1 deletion src/components/toaster/toaster.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Meta, StoryFn } from '@storybook/react';
import { Toaster } from './toaster';
import { toast } from './controller';
import { nanoid } from 'nanoid';
import { useState, useEffect } from 'react';

const meta: Meta<typeof Toaster> = {
title: 'Atoms/Toaster',
Expand Down Expand Up @@ -62,9 +64,15 @@ export default meta;
type Story = StoryFn<typeof Toaster>;

const Template: Story = ( args ) => {
const [ keyId, setKeyId ] = useState( nanoid() );

useEffect( () => {
setKeyId( nanoid() );
}, [ args ] );

return (
<div>
<Toaster { ...args } key={ args.position } />
<Toaster { ...args } key={ keyId } />
<div className="h-[100dvh] flex flex-col items-center justify-center">
<div className="flex gap-2">
<button
Expand Down
2 changes: 1 addition & 1 deletion src/components/toaster/toaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export const Toast = ( {
<div className="self-start flex items-center justify-center [&_svg]:size-5 shrink-0">
{ getIcon( { variant, icon, theme } ) }
</div>
<div className="flex flex-col items-start justify-start gap-0.5">
<div className="flex flex-col items-start justify-start gap-0.5 mr-6">
{ getTitle( { title, theme } ) }
{ getContent( { content, theme } ) }
{
Expand Down
51 changes: 33 additions & 18 deletions src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
isValidElement,
cloneElement,
useMemo,
Fragment,
} from 'react';
import {
useFloating,
Expand Down Expand Up @@ -174,21 +175,23 @@ export const Tooltip = ( {
const widthClasses = 'max-w-80 w-fit';

return (
<>
{ isValidElement( children ) &&
cloneElement( children as React.ReactElement, {
...children.props,
ref: mergeRefs(
(
children as React.ReactElement & {
ref?: React.Ref<HTMLElement>;
}
).ref,
refs.setReference
),
className: cn( children.props.className ),
...getReferenceProps(),
} ) }
<Fragment>
{ isValidElement( children ) && (
<Fragment key="tooltip-reference">
{ cloneElement( children as React.ReactElement, {
ref: mergeRefs(
(
children as React.ReactElement & {
ref?: React.Ref<HTMLElement>;
}
).ref,
refs.setReference
),
className: cn( children.props.className ),
...getReferenceProps(),
} ) }
</Fragment>
) }
<FloatingPortal id={ tooltipPortalId } root={ tooltipPortalRoot }>
{ isMounted && (
<div
Expand All @@ -207,10 +210,20 @@ export const Tooltip = ( {
>
<div>
{ !! title && (
<span className="font-semibold">{ title }</span>
<span
key="tooltip-title"
className="font-semibold"
>
{ title }
</span>
) }
{ !! content && (
<div className="font-normal">{ content }</div>
<div
key="tooltip-content"
className="font-normal"
>
{ content }
</div>
) }
</div>
{ arrow && (
Expand All @@ -223,8 +236,10 @@ export const Tooltip = ( {
</div>
) }
</FloatingPortal>
</>
</Fragment>
);
};

Tooltip.displayName = 'Tooltip';

export default Tooltip;
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"force-ui": "1.3.2"
"force-ui": "1.3.3"
}

0 comments on commit 757dbae

Please sign in to comment.