Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
new ConnectionCard and storybook integration (#55)
Browse files Browse the repository at this point in the history
* Logo updates

* New Connection Card and Storybook integration
  • Loading branch information
snrondina authored Oct 18, 2024
1 parent 204e8a0 commit 6765c53
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 9 deletions.
29 changes: 23 additions & 6 deletions packages/ui/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {dirname, join} from 'path'
const { dirname, join } = require('path')

/**
* This function is used to resolve the absolute path of a package.
Expand All @@ -25,10 +25,27 @@ const config = {
name: getAbsolutePath('@storybook/react-vite'),
options: {},
},
// viteFinal: async (config) => {
// config.css = config.css || {}
// config.css.postcss = require('../../../apps/web/postcss.config.js')
// return config
// },
// Add the following configuration to support SVGs
viteFinal: async (config) => {
// Ensure plugins array is initialized
if (!config.plugins) {
config.plugins = [];
}

config.plugins.push({
name: 'svgr',
transform: (code, id) => {
if (/\.svg$/.test(id)) {
return {
code: `import { ReactComponent as Icon } from '${id}'; export default Icon;`,
map: null,
};
}
return null;
},
});
return config;
},
}

export default config
38 changes: 38 additions & 0 deletions packages/ui/domain-components/ConnectionCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useState } from 'react'
import {
Card,
CardContent,
} from '../shadcn'
import { Plus } from 'lucide-react'

export function ConnectionCard({
logo,
name,
}: {
logo: string
name: string
}) {
const [isHovered, setIsHovered] = useState(false)

return (
<Card
className="w-[120px] h-[120px] p-0 relative cursor-pointer border border-gray-300 rounded-lg bg-white transition-colors duration-300 ease-in-out hover:bg-[#F8F7FF] hover:border-[#8A7DFF]"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
<CardContent className="flex flex-col justify-center items-center h-full pt-6">
{isHovered ? (
<div className="flex flex-col justify-center items-center h-full">
<Plus color="#8A7DFF" size={24} />
<span className="text-[#8A7DFF] font-semibold text-[14px] font-sans mt-2">Add</span> {/* Set to 14px and semibold */}
</div>
) : (
<div className="flex flex-col justify-center items-center h-full">
<img src={logo} alt={`${name} logo`} className="w-8 h-8" style={{ marginBottom: '10px' }} /> {/* 32x32 logo with 10px padding */}
<p className="m-0 text-sm font-semibold font-sans text-center mb-2">{name}</p> {/* Changed to font-semibold */}
</div>
)}
</CardContent>
</Card>
)
}
2 changes: 1 addition & 1 deletion packages/ui/shadcn/AlertDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
import * as React from 'react'

import {cn} from '@/lib-client/ui-utils'
import {cn} from '../utils'

import {buttonVariants} from './Button'

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/shadcn/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
import {Check} from 'lucide-react'
import * as React from 'react'

import {cn} from '@/lib-client/ui-utils'
import {cn} from '../utils'

const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/shadcn/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'

import {cn} from '@/lib-client/ui-utils'
import {cn} from '../utils'

const Table = React.forwardRef<
HTMLTableElement,
Expand Down
25 changes: 25 additions & 0 deletions packages/ui/stories/ConnectionCard.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {fn} from '@storybook/test'
import {ConnectionCard} from '../domain-components/ConnectionCard'
import logoGreenhouse from '../../../apps/web/public/_assets/logo-greenhouse.svg';
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
export default {
title: 'Example/ConnectionCard',
component: ConnectionCard,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
layout: 'centered',
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
// More on argTypes: https://storybook.js.org/docs/api/argtypes
argTypes: {
backgroundColor: {control: 'color'},
},
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
args: {onClick: fn()},
}

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Primary = {
args: { logo: logoGreenhouse, name: 'Greenhouse' },
};

0 comments on commit 6765c53

Please sign in to comment.