Skip to content

Commit

Permalink
Bump version to 0.48.23, enable DeepScan, and enhance ReqoreIcon and …
Browse files Browse the repository at this point in the history
…ReqorePanel components with new margin and description features
  • Loading branch information
Foxhoundn committed Dec 16, 2024
1 parent 4ed7788 commit ccfb325
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 197 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"deepscan.enable": true
}
352 changes: 188 additions & 164 deletions build-storybook.log

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qoretechnologies/reqore",
"version": "0.48.22",
"version": "0.48.23",
"description": "ReQore is a highly theme-able and modular UI library for React",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
13 changes: 8 additions & 5 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,11 @@ export interface IReqoreButtonBadgeProps extends IWithReqoreSize {
wrapGroup?: boolean;
compact?: boolean;
active?: boolean;
margin?: 'left' | 'none';
}

export const ButtonBadge = memo(
({ wrapGroup, compact, active, ...props }: IReqoreButtonBadgeProps) => {
({ wrapGroup, compact, active, margin = 'left', ...props }: IReqoreButtonBadgeProps) => {
const renderTag = useCallback(
({ size, color, theme, content, key }: IReqoreButtonBadgeProps & { key: number }) => (
<ReqoreTag
Expand Down Expand Up @@ -418,10 +419,12 @@ export const ButtonBadge = memo(

return (
<>
<ReqoreSpacer
width={props.wrap ? undefined : PADDING_FROM_SIZE[props.size] / (compact ? 2 : 1)}
height={!props.wrap ? undefined : PADDING_FROM_SIZE[props.size] / 2}
/>
{margin === 'left' && (
<ReqoreSpacer
width={props.wrap ? undefined : PADDING_FROM_SIZE[props.size] / (compact ? 2 : 1)}
height={!props.wrap ? undefined : PADDING_FROM_SIZE[props.size] / 2}
/>
)}
{size(leftBadges) ? (
<ReqoreTagGroup wrap={wrapGroup} align='left'>
{leftBadges.map((badge, index) =>
Expand Down
22 changes: 19 additions & 3 deletions src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export interface IReqoreIconProps
wrapperSize?: TSizes | string;
wrapperElement?: any;
iconProps?: IconBaseProps;

margin?: 'right' | 'left' | 'both';
marginSize?: TSizes | string | number;

image?: string;
rounded?: boolean;
rotation?: number;
Expand Down Expand Up @@ -55,18 +58,22 @@ export const StyledIconWrapper = styled(StyledEffect)<{ margin: 'right' | 'left'
rotate: ${({ rotation }) => (rotation ? `${rotation}deg` : undefined)};
cursor: ${({ interactive }) => (interactive ? 'pointer' : undefined)};
${({ margin, size, compact }) =>
${({ margin, marginSize, size, compact }) =>
margin &&
css`
margin-left: ${margin === 'left' || margin === 'both'
? isStringSize(size)
? marginSize
? `${marginSize}px`
: isStringSize(size)
? `${PADDING_FROM_SIZE[size] / (compact ? 2 : 1)}px`
: compact
? '3px'
: '6px'
: undefined};
margin-right: ${margin === 'right' || margin === 'both'
? isStringSize(size)
? marginSize
? `${marginSize}px`
: isStringSize(size)
? `${PADDING_FROM_SIZE[size] / (compact ? 2 : 1)}px`
: compact
? '3px'
Expand Down Expand Up @@ -95,7 +102,10 @@ const ReqoreIcon = memo(
wrapperElement,
className,
color,

margin,
marginSize,

style = {},
iconProps,
intent,
Expand All @@ -118,6 +128,9 @@ const ReqoreIcon = memo(
? ICON_FROM_SIZE[wrapperSize]
: wrapperSize
: finalSize;
const finalMarginSize: number = isStringSize(marginSize)
? PADDING_FROM_SIZE[marginSize]
: marginSize;

useTooltip(iconRef, tooltip);

Expand All @@ -129,6 +142,7 @@ const ReqoreIcon = memo(
ref={targetRef}
size={size}
margin={margin}
marginSize={finalMarginSize}
className={`${className || ''} reqore-icon`}
style={{ width: finalWrapperSize, height: finalWrapperSize, ...style }}
>
Expand All @@ -145,6 +159,7 @@ const ReqoreIcon = memo(
ref={targetRef}
size={size}
margin={margin}
marginSize={finalMarginSize}
className={`${className || ''} reqore-icon`}
style={{ width: finalWrapperSize, height: finalWrapperSize, ...style }}
/>
Expand All @@ -161,6 +176,7 @@ const ReqoreIcon = memo(
}}
margin={margin}
size={size}
marginSize={finalMarginSize}
style={{ width: finalWrapperSize, height: finalWrapperSize, ...style }}
className={`${className || ''} reqore-icon`}
>
Expand Down
83 changes: 60 additions & 23 deletions src/components/Panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import {
GAP_FROM_SIZE,
HEADER_SIZE_TO_NUMBER,
ICON_FROM_HEADER_SIZE,
NUMBER_TO_SIZE,
PADDING_FROM_SIZE,
RADIUS_FROM_SIZE,
SIZE_TO_PX,
TEXT_FROM_SIZE,
TSizes,
} from '../../constants/sizes';
import { IReqoreTheme } from '../../constants/theme';
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
import {
changeDarkness,
changeLightness,
Expand Down Expand Up @@ -47,6 +48,7 @@ import ReqoreDropdown from '../Dropdown';
import { IReqoreDropdownItem } from '../Dropdown/list';
import { IReqoreEffect, StyledEffect, TReqoreEffectColor } from '../Effect';
import ReqoreIcon, { IReqoreIconProps, StyledIconWrapper } from '../Icon';
import { ReqoreSpan } from '../Span';
import { LabelEditor } from './LabelEditor';
import { ReqorePanelNonResponsiveActions } from './NonResponsiveActions';

Expand Down Expand Up @@ -86,10 +88,13 @@ export interface IReqorePanelProps
React.HTMLAttributes<HTMLDivElement> {
as?: any;
children?: any;

icon?: IReqoreIconName;
iconProps?: IReqoreIconProps;
label?: string | ReactElement<any>;
badge?: TReqoreBadge | TReqoreBadge[];
description?: string;

collapsible?: boolean;
isCollapsed?: boolean;
collapseButtonProps?: IReqoreButtonProps;
Expand Down Expand Up @@ -121,6 +126,8 @@ export interface IReqorePanelProps
contentSize?: TSizes;
contentEffect?: IReqoreEffect;
headerEffect?: IReqoreEffect;
descriptionEffect?: IReqoreEffect;
descriptionIntent?: TReqoreIntent;
transparent?: boolean;
iconColor?: TReqoreEffectColor;
responsiveActions?: boolean;
Expand Down Expand Up @@ -164,6 +171,19 @@ export const StyledPanelTitleHeaderContent = styled.div`
}}px;
`;

export const StyledPanelTitleHeaderLabelAndDescription = styled.div`
display: flex;
flex-flow: column;
gap: 3px;
min-width: 0;
flex: 1 auto;
`;

export const StyledPanelTitleHeaderLabelAndBadge = styled.div`
display: inline-flex;
max-width: 100%;
`;

export type TPanelStyle = React.FC<
Omit<IReqorePanelProps, 'onResize' | 'size'> &
ResizableProps & {
Expand Down Expand Up @@ -347,6 +367,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
{
children,
label,
description,
collapseButtonProps = {},
collapsible,
onClose,
Expand All @@ -367,6 +388,8 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
contentStyle,
contentEffect,
headerEffect = {},
descriptionEffect = {},
descriptionIntent,
headerSize,
contentSize,
minimal,
Expand Down Expand Up @@ -764,30 +787,44 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
}
/>
) : null}
{typeof label === 'string' ? (
<LabelEditor
size={headerSize || panelSize}
customTheme={theme}
effect={{
noWrap: true,
...headerEffect,
}}
label={label}
onSubmit={onLabelEdit}
tooltip={showHeaderTooltip ? label : undefined}
/>
) : (
label
)}
<StyledPanelTitleHeaderLabelAndDescription>
<StyledPanelTitleHeaderLabelAndBadge>
{typeof label === 'string' ? (
<LabelEditor
size={headerSize || panelSize}
customTheme={theme}
effect={{
noWrap: true,
...headerEffect,
}}
label={label}
onSubmit={onLabelEdit}
tooltip={showHeaderTooltip ? label : undefined}
/>
) : (
label
)}
{badge || badge === 0 ? (
<ButtonBadge
size={getOneHigherSize(panelSize)}
content={badge}
wrapGroup={isSmall}
margin={label ? 'left' : 'none'}
/>
) : null}
</StyledPanelTitleHeaderLabelAndBadge>
{description && (
<ReqoreSpan
size={headerSize ? NUMBER_TO_SIZE[headerSize] : panelSize}
effect={{ opacity: 0.7, ...descriptionEffect }}
intent={descriptionIntent}
>
{description}
</ReqoreSpan>
)}
</StyledPanelTitleHeaderLabelAndDescription>
</StyledPanelTitleHeaderContent>
) : null}
{badge || badge === 0 ? (
<ButtonBadge
size={getOneHigherSize(panelSize)}
content={badge}
wrapGroup={isSmall}
/>
) : null}
<ReqorePanelNonResponsiveActions
show={isSmall && (!!onClose || collapsible)}
isSmall={isSmall}
Expand Down
10 changes: 10 additions & 0 deletions src/stories/Icon/Icon.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ export const Basic: Story = {
<ReqoreIcon icon='HotelFill' margin='both' />
Sides
</div>
<div>
Huge
<ReqoreIcon icon='HotelFill' margin='both' marginSize={50} />
Margins
</div>
<div>
Tiny
<ReqoreIcon icon='HotelFill' margin='both' marginSize='tiny' />
Margins
</div>
</ReqorePanel>
</>
);
Expand Down
23 changes: 23 additions & 0 deletions src/stories/Panel/Panel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -761,3 +761,26 @@ export const Loading: Story = {
loading: true,
},
};

export const WithDescription: Story = {
render: Template,

args: {
description: 'This is a description',
},
};

export const WithLongDescription: Story = {
render: Template,

args: {
minimal: true,
descriptionIntent: 'info',
descriptionEffect: {
uppercase: true,
textSize: 'small',
},
description:
'This is a very long description that should be wrapped and not overflow, but it should be long enough to test the wrapping',
},
};

0 comments on commit ccfb325

Please sign in to comment.