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

Update Components and Include New Icons #1

Merged
merged 17 commits into from
Mar 27, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
junit.xml

/dist
/yarn-error.log
/yarn.lock
/sample
/__reports__
/node_modules/
Expand Down
47 changes: 47 additions & 0 deletions .storybook/figmaAddon/register.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { addons, types } from '@storybook/addons';
import { IconButton } from '@storybook/components';
import { useParameter } from '@storybook/manager-api';
import { styled } from '@storybook/theming';

import React from 'react';

const ADDON_ID = 'myaddon/figma';
const PARAM_KEY = 'figmaUrl';

const FigmaIcon = styled.img({
width: '20px',
height: '20px',
marginRight: '10px',
});

addons.register(ADDON_ID, () => {
addons.add(ADDON_ID, {
title: 'Figma',
type: types.TOOL,
match: ({ viewMode }) => viewMode === 'story',
render: () => {
const figmaLink = useParameter(PARAM_KEY, '#');

if (figmaLink === '#') {
return null;
}

return (
<IconButton
key="figma"
title="Open in Figma"
onClick={() => window.open(figmaLink, '_blank')}
placeholder={''}
onPointerEnterCapture={undefined}
onPointerLeaveCapture={undefined}
>
<FigmaIcon
src="data:image/svg+xml;base64,PHN2ZyBpZD0iRmxhdCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMjU2IDI1NiI+CiAgPHBhdGggZD0iTTE4My4wMzk1NSw5NC4wMDA0OUEzOS45ODcwNiwzOS45ODcwNiwwLDAsMCwxNjIsMjAuMDAxSDk0QTM5Ljk4Nz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@@
import { addons, types } from '@storybook/addons';
import { IconButton } from '@storybook/components';
import { useParameter } from '@storybook/manager-api';
import { styled } from '@storybook/theming';

import React from 'react';

const ADDON_ID = 'myaddon/github';
const PARAM_KEY = 'githubUrl';

const GithubIcon = styled.img({
width: '20px',
height: '20px',
marginRight: '10px',
});

addons.register(ADDON_ID, () => {
addons.add(ADDON_ID, {
title: 'Github',
type: types.TOOL,
match: ({ viewMode }) => viewMode === 'story',
render: () => {
const githubLink = useParameter(PARAM_KEY, '#');

if (githubLink === '#') {
return null;
}

return (
<IconButton
key="github"
title="Open in Github"
onClick={() => window.open(githubLink, '_blank')}
placeholder={''}
onPointerEnterCapture={undefined}
onPointerLeaveCapture={undefined}
>
<GithubIcon
src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgaWQ9Imljb25fZ2l0aHViIj4KPHBhdGggaWQ9IlZlY3RvciIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMiAxQzUuOTIyNSAxIDEgNS45MjI1IDEgMTJDMSAxNi44Njc1IDQuMTQ4NzUgMjAuOTc4OCA4LjUyMTI1IDIyLjQzNjNDOS4wNzEyNSAyMi41MzI1IDkuMjc3NSAyMi4yMDI1IDkuMjc3NSAyMS45MTM3QzkuMjc3NSAyMS42NTI1IDkuMjYzNzUgMjAuNzg2MyA5LjI2Mzc1IDE5Ljg2NUM2LjUgMjAuMzczOCA1Ljc4NSAxOS4xOTEyIDUuNTY1IDE4LjU3MjVDNS40NDEyNSAxOC4yNTYzIDQuOTA1IDE3LjI4IDQuNDM3NSAxNy4wMTg3QzQuMDUyNSAxNi44MTI1IDMuNTAyNSAxNi4zMDM4IDQuNDIzNzUgMTYuMjlDNS4yOSAxNi4yNz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wvZz4KPC9zdmc+Cg=="
alt="github"
/>
Github
</IconButton>
);
},
});
});
2 changes: 2 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const config: StorybookConfig = {
'@storybook/addon-a11y',
'@storybook/addon-coverage',
'./tokensAddons/register.tsx',
'./figmaAddon/register.tsx',
'./githubAddon/register.tsx',
],
framework: {
name: '@storybook/react-vite',
Expand Down
25 changes: 21 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"name": "@kubit-ui-web/react-components",
"version": "1.0.0",
"version": "1.1.0",
"description": "Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience",
"author": "Kubit",
"author": {
"name": "Kubit",
"email": "kubit@opendigitalservices.com",
"url": "https://www.kubit-ui.com/",
"organization": "Kubit",
"organizationUrl": "https://www.kubit-ui.com/",
"role": "Developer",
"roleUrl": "https://www.kubit-ui.com/",
"social": {
"twitter": "https://twitter.com/kubit_ui",
"github": "https://github.com/kubit-ui/kubit-react-components"
}
},
"private": false,
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
Expand Down Expand Up @@ -59,7 +71,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/kubit-ui/kubit-react-components"
"url": "git+https://github.com/kubit-ui/kubit-react-components.git"
},
"sideEffects": false,
"license": "Apache-2.0",
Expand Down Expand Up @@ -96,6 +108,7 @@
"@typescript-eslint/parser": "^7.1.0",
"@vitejs/plugin-react": "^4.2.1",
"babel-jest": "^29.7.0",
"chromatic": "^11.2.0",
"cpy-cli": "^5.0.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand Down Expand Up @@ -150,5 +163,9 @@
"wrap-ansi": "^7.0.0",
"@typescript-eslint/utils": "6.13.0",
"@babel/highlight": "7.24.1 "
}
},
"bugs": {
"url": "https://github.com/kubit-ui/kubit-react-components/issues"
},
"homepage": "https://www.kubit-ui.com/"
}
6 changes: 6 additions & 0 deletions src/components/accordion/stories/accordion.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ const meta = {
component: AccordionStory,
tags: ['autodocs'],
argTypes: argtypes(variantsObject, themeSelected),
parameters: {
githubUrl:
'https://github.com/kubit-ui/kubit-react-components/tree/main/src/components/accordion',
figmaUrl:
'https://www.figma.com/file/EYQkbENTFO5r8muvXlPoOy/Kubit-v.1.0.0?type=design&node-id=3922-22906',
},
} satisfies Meta<typeof AccordionStory>;

export default meta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const meta = {
component: Story,
parameters: {
layout: 'centered',
githubUrl:
'https://github.com/kubit-ui/kubit-react-components/tree/main/src/components/actionBottomSheet',
figmaUrl:
'https://www.figma.com/file/EYQkbENTFO5r8muvXlPoOy/Kubit-v.1.0.0?type=design&node-id=3922-22902',
},
tags: ['autodocs'],
argTypes: argtypes(variantsObject, themeSelected),
Expand Down
3 changes: 3 additions & 0 deletions src/components/avatar/stories/avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const meta = {
component: AvatarStory,
parameters: {
layout: 'centered',
githubUrl: 'https://github.com/kubit-ui/kubit-react-components/tree/main/src/components/avatar',
figmaUrl:
'https://www.figma.com/file/EYQkbENTFO5r8muvXlPoOy/Kubit-v.1.0.0?type=design&node-id=3928-34082&mode=dev',
},
tags: ['autodocs'],
argTypes: argtypes(variantsObject, themeSelected),
Expand Down
5 changes: 3 additions & 2 deletions src/components/backToTop/__tests__/backToTop.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ describe('BackToTop component', () => {

test('When scrollY is >= visibilityScrollOffset the button will be shown', () => {
const scrollToMock = jest.fn();
const ref = React.createRef<HTMLButtonElement>();
jest.spyOn(window, 'scrollTo').mockImplementation(scrollToMock);
window.scrollY = 2;

const ref = React.createRef<HTMLButtonElement>();
renderProvider(
<div>
<BackToTop {...mockProps} />
<BackToTop {...mockProps} ref={ref} />
<footer>footer</footer>
</div>
);
Expand Down
4 changes: 4 additions & 0 deletions src/components/backToTop/stories/backToTop.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const meta = {
component: Story,
parameters: {
layout: 'centered',
githubUrl:
'https://github.com/kubit-ui/kubit-react-components/tree/main/src/components/backToTop',
figmaUrl:
'https://www.figma.com/file/EYQkbENTFO5r8muvXlPoOy/Kubit-v.1.0.0?type=design&node-id=3922-9956&mode=dev',
},
tags: ['autodocs'],
argTypes: argtypes(variantsObject, themeSelected),
Expand Down
4 changes: 4 additions & 0 deletions src/components/breadcrumbs/stories/breadcrumbs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const meta = {
component: Story,
parameters: {
layout: 'centered',
githubUrl:
'https://github.com/kubit-ui/kubit-react-components/tree/main/src/components/breadcrumbs',
figmaUrl:
'https://www.figma.com/file/EYQkbENTFO5r8muvXlPoOy/Kubit-v.1.0.0?type=design&node-id=3942-37705',
},
tags: ['autodocs'],
argTypes: argtypes(variantsObject, themeSelected),
Expand Down
3 changes: 3 additions & 0 deletions src/components/button/stories/button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const meta = {
component: ButtonStory,
parameters: {
layout: 'centered',
githubUrl: 'https://github.com/kubit-ui/kubit-react-components/tree/main/src/components/button',
figmaUrl:
'https://www.figma.com/file/EYQkbENTFO5r8muvXlPoOy/Kubit-v.1.0.0?type=design&node-id=3922-9829',
},
tags: ['autodocs'],
argTypes: argtypes(variantsObject, themeSelected),
Expand Down
4 changes: 4 additions & 0 deletions src/components/calendar/stories/calendar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const meta = {
component: Story,
parameters: {
layout: 'centered',
githubUrl:
'https://github.com/kubit-ui/kubit-react-components/tree/main/src/components/calendar',
figmaUrl:
'https://www.figma.com/file/EYQkbENTFO5r8muvXlPoOy/Kubit-v.1.0.0?type=design&node-id=3922-29766',
},
tags: ['autodocs'],
argTypes: argtypes(variantsObject, themeSelected),
Expand Down
2 changes: 1 addition & 1 deletion src/components/carousel/carousel.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const CarouselContentStyled = styled.div<{
left: 0;
display: flex;
flex-direction: row;
align-items: center;
align-items: stretch;
> * {
flex-shrink: 0;
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/carousel/stories/carousel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ const meta = {
component: Story,
tags: ['autodocs'],
argTypes: argtypes(variantsObject, themeSelected),
parameters: {
githubUrl:
'https://github.com/kubit-ui/kubit-react-components/tree/main/src/components/carousel',
figmaUrl:
'https://www.figma.com/file/EYQkbENTFO5r8muvXlPoOy/Kubit-v.1.0.0?type=design&node-id=3942-37713&mode=dev',
},
} satisfies Meta<typeof Story>;

export default meta;
Expand Down
Loading