Skip to content

Commit

Permalink
Merge branch 'task-6780' of github.com:makafsal/ibm-products into tas…
Browse files Browse the repository at this point in the history
…k-6780
  • Loading branch information
makafsal committed Mar 3, 2025
2 parents bb63924 + 159c2ad commit 5d25440
Show file tree
Hide file tree
Showing 12 changed files with 1,716 additions and 2,064 deletions.
2 changes: 1 addition & 1 deletion actions/add-review-labels/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@actions/core": "^1.2.3",
"@actions/github": "^6.0.0",
"decompress": "^4.2.1",
"octokit": "^4.0.2"
"octokit": "^4.1.2"
}
}
14 changes: 7 additions & 7 deletions config/storybook-addon-carbon-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
},
"dependencies": {
"@ibm/telemetry-js": "^1.8.0",
"@storybook/addons": "^7.6.17",
"@storybook/api": "^7.6.17",
"@storybook/client-api": "^7.6.17",
"@storybook/client-logger": "^8.4.7",
"@storybook/components": "^8.4.7",
"@storybook/core-events": "^8.4.7",
"@storybook/theming": "^8.4.7",
"@storybook/addons": "7.6.17",
"@storybook/api": "7.6.17",
"@storybook/client-api": "7.6.17",
"@storybook/client-logger": "^8.6.2",
"@storybook/components": "^8.6.2",
"@storybook/core-events": "^8.6.2",
"@storybook/theming": "^8.6.2",
"core-js": "^3.40.0",
"global": "^4.4.0"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/core/.storybook/Annotation/_annotation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ $types: (
background: tag.$tag-background-teal,
color: tag.$tag-color-teal,
),
'layer': (
border: colors.$purple-40,
background: tag.$tag-background-purple,
color: tag.$tag-color-purple,
),
);

.#{$pkg-prefix}--annotation {
Expand Down
10 changes: 8 additions & 2 deletions packages/core/.storybook/Annotation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ const types = {
},
};

export const Annotation = ({ className, type, text, children }) => {
export const Annotation = ({
className,
type = 'layer',
text,
children,
icon: IconProp,
}) => {
const Icon = types[type].icon;
return (
<div
Expand All @@ -34,7 +40,7 @@ export const Annotation = ({ className, type, text, children }) => {
)}
>
<div className={`${pkg.prefix}--annotation__label`}>
<Icon />
{IconProp ? <IconProp /> : <Icon />}
{text}
</div>
<div className={`${pkg.prefix}--annotation__content`}>{children}</div>
Expand Down
1 change: 1 addition & 0 deletions packages/core/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const parameters = {
['Components', 'Patterns', 'Onboarding'],
'Utils',
['Components'],
'Hooks',
'Deprecated',
],
},
Expand Down
32 changes: 16 additions & 16 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@
"@carbon/type": "^11.35.0",
"@percy/cli": "^1.30.6",
"@percy/storybook": "^6.0.3",
"@storybook/addon-a11y": "^8.4.7",
"@storybook/addon-actions": "^8.4.7",
"@storybook/addon-controls": "^8.4.7",
"@storybook/addon-docs": "^8.4.7",
"@storybook/addon-essentials": "^8.4.7",
"@storybook/addon-links": "^8.4.7",
"@storybook/addon-storysource": "^8.4.7",
"@storybook/addon-viewport": "^8.4.7",
"@storybook/components": "^8.4.7",
"@storybook/core-events": "^8.4.7",
"@storybook/addon-a11y": "^8.6.2",
"@storybook/addon-actions": "^8.6.2",
"@storybook/addon-controls": "^8.6.2",
"@storybook/addon-docs": "^8.6.2",
"@storybook/addon-essentials": "^8.6.2",
"@storybook/addon-links": "^8.6.2",
"@storybook/addon-storysource": "^8.6.2",
"@storybook/addon-viewport": "^8.6.2",
"@storybook/components": "^8.6.2",
"@storybook/core-events": "^8.6.2",
"@storybook/csf": "^0.1.13",
"@storybook/manager-api": "^8.4.7",
"@storybook/react": "^8.4.7",
"@storybook/react-vite": "^8.4.7",
"@storybook/source-loader": "^8.4.7",
"@storybook/theming": "^8.4.7",
"@storybook/manager-api": "^8.6.2",
"@storybook/react": "^8.6.2",
"@storybook/react-vite": "^8.6.2",
"@storybook/source-loader": "^8.6.2",
"@storybook/theming": "^8.6.2",
"fast-glob": "^3.3.3",
"npm-check-updates": "^17.1.13",
"npm-run-all": "^4.1.5",
Expand All @@ -63,7 +63,7 @@
"remark-gfm": "^4.0.0",
"rimraf": "^6.0.1",
"sass": "^1.83.4",
"storybook": "^8.4.7",
"storybook": "^8.6.2",
"typescript": "^5.7.3",
"vite": "^6.0.7"
},
Expand Down
18 changes: 9 additions & 9 deletions packages/ibm-products-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-typescript": "^12.1.1",
"@storybook/addon-essentials": "^8.4.5",
"@storybook/addon-links": "^8.4.5",
"@storybook/addon-storysource": "^8.4.5",
"@storybook/addon-toolbars": "^8.4.5",
"@storybook/blocks": "^8.4.5",
"@storybook/theming": "^8.4.5",
"@storybook/web-components": "^8.4.5",
"@storybook/web-components-vite": "^8.4.5",
"@storybook/addon-essentials": "^8.6.2",
"@storybook/addon-links": "^8.6.2",
"@storybook/addon-storysource": "^8.6.2",
"@storybook/addon-toolbars": "^8.6.2",
"@storybook/blocks": "^8.6.2",
"@storybook/theming": "^8.6.2",
"@storybook/web-components": "^8.6.2",
"@storybook/web-components-vite": "^8.6.2",
"@types/jest": "^29.5.13",
"@vitest/browser": "^3.0.1",
"@vitest/coverage-v8": "^3.0.1",
Expand All @@ -90,7 +90,7 @@
"rollup": "^4.27.3",
"rollup-plugin-copy": "^3.5.0",
"sass": "^1.80.6",
"storybook": "^8.4.5",
"storybook": "^8.6.2",
"storybook-addon-accessibility-checker": "^3.1.61-rc.3",
"tslib": "^2.8.1",
"typescript": "^5.5.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright IBM Corp. 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

.slider {
/* stylelint-disable-next-line carbon/layout-use */
margin-block-end: 1rem;
}

.parent {
overflow: scroll;
max-inline-size: 100%;
scrollbar-width: none;
}

.child {
white-space: nowrap;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright IBM Corp. 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

export { useOverflowItems } from './useOverflowItems';
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* Copyright IBM Corp. 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import React, { useRef, useState } from 'react';
import { useOverflowItems } from './useOverflowItems';
import { Tag, Slider } from '@carbon/react';
import { Annotation } from '../../../../../../core/.storybook/Annotation';
import { FitToWidth } from '@carbon/react/icons';
import './_storybook-styles.scss';

export default {
title: 'Hooks/useOverflowItems',
parameters: {
layout: 'padded',
},
};

const Template = () => {
const [width, setWidth] = useState(500);
const [numberOfTags, setNumberOfTags] = useState(10);
const containerRef = useRef(null);

const makeTags = (n) => {
return Array(n)
.fill(null)
.map((_, idx) => ({
id: idx,
label: `Tag ${idx + 1}`,
}));
};

const tags = makeTags(numberOfTags);

const { visibleItems, hiddenItems, itemRefHandler } = useOverflowItems(
tags,
containerRef
);

const widthHandler = (n) => {
setWidth(n);
};

return (
<div>
<Slider
className="slider"
max={1000}
min={200}
value={width}
onChange={({ value }) => widthHandler(value)}
hideTextInput
labelText="Parent container width"
/>
<Slider
className="slider"
max={50}
min={1}
value={numberOfTags}
onChange={({ value }) => setNumberOfTags(value)}
hideTextInput
labelText="Number of total tags"
/>
<div
className="parent"
style={{
width: `${width}px`,
}}
>
<Annotation text="Parent container" type="layer" icon={FitToWidth}>
<div className="child" ref={containerRef}>
<p>Visible items:</p>
{visibleItems.map((tag) => (
<Tag
type="blue"
key={tag.id}
ref={(node) => {
itemRefHandler(tag.id, node);
}}
>
{tag.label}
</Tag>
))}
</div>
<div>
<p>Hidden items:</p>
{hiddenItems.map((tag) => (
<Tag key={tag.id} type="blue">
{tag.label}
</Tag>
))}
</div>
</Annotation>
</div>
</div>
);
};

export const DefaultUsage = Template.bind({});
DefaultUsage.args = {};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { RefObject, useRef, useState } from 'react';
import { useResizeObserver } from './useResizeObserver';
import { useResizeObserver } from '../useResizeObserver';

type Item = {
id: string;
Expand Down
Loading

0 comments on commit 5d25440

Please sign in to comment.