Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

feat: revamp collection details #297

Merged
merged 26 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6721b3a
init
kasperkristensen Feb 1, 2022
412f011
Merge branch 'feat/revamp' into feat/revamp-collection-details
kasperkristensen Feb 1, 2022
02ac03a
merged revamp
kasperkristensen Feb 1, 2022
a781dfc
merge feat/revamp
kasperkristensen Feb 1, 2022
bd13296
progress
kasperkristensen Feb 1, 2022
9b1a457
created raw data component
kasperkristensen Feb 1, 2022
932f270
finalize component
kasperkristensen Feb 1, 2022
df756ef
fixed chevron icon
kasperkristensen Feb 1, 2022
afacd71
added optional name
kasperkristensen Feb 1, 2022
4c276fc
Merge branch 'feat/raw-data-component' into feat/revamp-collection-de…
kasperkristensen Feb 1, 2022
edca547
progress on table
kasperkristensen Feb 2, 2022
a92ad34
progress on add product
kasperkristensen Feb 2, 2022
480ac31
commit changes
kasperkristensen Feb 2, 2022
bbdefc8
progress
kasperkristensen Feb 2, 2022
ee4eeb4
Merge branch 'feat/revamp' into feat/revamp-collection-details
kasperkristensen Feb 2, 2022
d77c1b6
progress on modal
kasperkristensen Feb 2, 2022
d93c379
merge feat/revamp
kasperkristensen Feb 2, 2022
c996929
push progress
kasperkristensen Feb 2, 2022
c74f860
metadata
kasperkristensen Feb 2, 2022
c7ad454
add products finished except api request
kasperkristensen Feb 2, 2022
18fb636
refractor
kasperkristensen Feb 3, 2022
aaeb69b
pagination
kasperkristensen Feb 3, 2022
7c0477f
final collection details
kasperkristensen Feb 3, 2022
01b8649
clean up
kasperkristensen Feb 3, 2022
792e828
Merge branch 'feat/Revamp' into feat/revamp-collection-details
kasperkristensen Feb 3, 2022
5a446f8
fix merge conflicts
olivermrbl Feb 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"@storybook/addon-postcss": "^2.0.0",
"@storybook/react": "^6.4.9",
"@storybook/theming": "^6.4.9",
"@tailwindcss/forms": "^0.4.0",
"@tailwindcss/line-clamp": "^0.3.1",
"@types/react-table": "^7.7.9",
"@typescript-eslint/parser": "^5.9.1",
Expand Down
17 changes: 17 additions & 0 deletions src/components/atoms/checkbox/checkbox.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ComponentMeta, ComponentStory } from "@storybook/react"
import React from "react"
import Checkbox from "."

export default {
title: "Atoms/Checkbox",
component: Checkbox,
} as ComponentMeta<typeof Checkbox>

const Template: ComponentStory<typeof Checkbox> = (args) => (
<Checkbox {...args} />
)

export const Default = Template.bind({})
Default.args = {
label: "Checkbox",
}
35 changes: 35 additions & 0 deletions src/components/atoms/checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import clsx from "clsx"
import React, { useImperativeHandle } from "react"

type CheckboxProps = React.InputHTMLAttributes<HTMLInputElement> & {
label: string
}

const Checkbox = React.forwardRef(
({ label, value, className, id, ...rest }: CheckboxProps, ref) => {
const checkboxRef = React.useRef<HTMLInputElement>(null)

useImperativeHandle(ref, () => checkboxRef.current)
return (
<label
className={clsx(
"flex items-center inter-base-semibold cursor-pointer",
className
)}
htmlFor={id}
>
<input
type="checkbox"
ref={checkboxRef}
className="form-checkbox w-[20px] h-[20px] rounded-base text-violet-60 focus:ring-0 mr-small border-grey-30"
value={value}
id={id}
{...rest}
/>
{label}
</label>
)
}
)

export default Checkbox
2 changes: 1 addition & 1 deletion src/components/fundamentals/icons/check-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import IconProps from "./types/icon-type"
const CheckIcon: React.FC<IconProps> = ({
size = "24px",
color = "currentColor",
attributes,
...attributes
}) => {
return (
<svg
Expand Down
58 changes: 58 additions & 0 deletions src/components/molecules/indeterminate-checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React, { forwardRef, useEffect, useRef } from "react"
import CheckIcon from "../../fundamentals/icons/check-icon"

interface Props {
indeterminate?: boolean
name: string
}

const useCombinedRefs = (...refs): React.MutableRefObject<any> => {
const targetRef = React.useRef()

React.useEffect(() => {
refs.forEach((ref) => {
if (!ref) {
return
}

if (typeof ref === "function") {
ref(targetRef.current)
} else {
ref.current = targetRef.current
}
})
}, [refs])

return targetRef
}

const IndeterminateCheckbox = forwardRef<HTMLInputElement, Props>(
({ indeterminate, ...rest }, ref: React.Ref<HTMLInputElement>) => {
const defaultRef = useRef(null)
const combinedRef = useCombinedRefs(ref, defaultRef)

useEffect(() => {
if (combinedRef?.current) {
combinedRef.current.indeterminate = indeterminate ?? false
}
}, [combinedRef, indeterminate])

return (
<div className="items-center h-full flex">
<div
onClick={() => combinedRef.current?.click()}
className={`w-5 h-5 flex justify-center text-grey-0 border-grey-30 border cursor-pointer rounded-base ${
combinedRef.current?.checked && "bg-violet-60"
}`}
>
<span className="self-center">
{combinedRef.current?.checked && <CheckIcon size={16} />}
</span>
</div>
<input type="checkbox" className="hidden" ref={combinedRef} {...rest} />
</div>
)
}
)

export default IndeterminateCheckbox
4 changes: 3 additions & 1 deletion src/components/molecules/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ const Table: TableType = React.forwardRef(
return (
<div className="flex flex-col">
<div className="w-full flex justify-between mb-2">
{filteringOptions && (
{filteringOptions ? (
<div className="flex mb-2 self-end">
{Array.isArray(filteringOptions)
? filteringOptions.map((fo) => <FilteringOptions {...fo} />)
: filteringOptions}
</div>
) : (
<span />
)}
<div className="flex">
{enableSearch && (
Expand Down
18 changes: 11 additions & 7 deletions src/components/molecules/view-raw/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState } from "react"
import ReactJson from "react-json-view"
import * as Collapsible from "@radix-ui/react-collapsible"
import ChevronDownIcon from "../../fundamentals/icons/chevron-down"
import Button from "../../fundamentals/button"
import clsx from "clsx"
import React, { useState } from "react"
import ReactJson from "react-json-view"
import useClipboard from "../../../hooks/use-clipboard"
import Button from "../../fundamentals/button"
import ChevronDownIcon from "../../fundamentals/icons/chevron-down"
import ClipboardCopyIcon from "../../fundamentals/icons/clipboard-copy-icon"

type ViewRawProps = {
Expand All @@ -31,7 +31,8 @@ const ViewRaw: React.FC<ViewRawProps> = ({ raw, title = "Data", name }) => {
<p className="inter-base-semibold">
{title}{" "}
<span className="inter-base-regular text-grey-50">
({Object.keys(raw).length})
({Object.keys(raw).length}{" "}
{Object.keys(raw).length === 1 ? "item" : "items"})
</span>
</p>
<Button variant="ghost" size="small" className="text-grey-50">
Expand All @@ -49,11 +50,11 @@ const ViewRaw: React.FC<ViewRawProps> = ({ raw, title = "Data", name }) => {
<ReactJson
src={raw}
enableClipboard={false}
shouldCollapse={false}
style={{
fontFamily: "Roboto Mono",
fontSize: "12px",
}}
shouldCollapse={false}
name={name}
/>
</div>
Expand All @@ -63,7 +64,10 @@ const ViewRaw: React.FC<ViewRawProps> = ({ raw, title = "Data", name }) => {
variant="ghost"
size="small"
type="button"
onClick={handleCopy}
onClick={(e) => {
e.currentTarget.blur()
handleCopy()
}}
>
<ClipboardCopyIcon size={20} />
</Button>
Expand Down
20 changes: 0 additions & 20 deletions src/components/organisms/add-metadata/add-metadata.stories.tsx

This file was deleted.

117 changes: 0 additions & 117 deletions src/components/organisms/add-metadata/index.tsx

This file was deleted.

59 changes: 59 additions & 0 deletions src/components/organisms/add-product-modal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from "react"
import Button from "../../fundamentals/button"
import Modal from "../../molecules/modal"
import AddProductsTable from "../../templates/collection-product-table/add-product-table"

type AddProductModalProps = {
handleClose: () => void
onSubmit: (ids: any[]) => void
collectionProducts: any[]
}

const AddProductModal: React.FC<AddProductModalProps> = ({
handleClose,
onSubmit,
collectionProducts,
}) => {
const [selectedProducts, setSelectedProducts] = React.useState<any[]>([])

const handleSelectProduct = () => {
if (selectedProducts.length > 0) {
onSubmit(selectedProducts.map((p) => p.id))
}
}

return (
<Modal handleClose={handleClose}>
<Modal.Body>
<Modal.Header handleClose={handleClose}>
<h3 className="inter-xlarge-semibold">Add Products</h3>
</Modal.Header>
<Modal.Content>
<div className="h-[650px]">
<AddProductsTable
addedProducts={collectionProducts}
setProducts={setSelectedProducts}
/>
</div>
</Modal.Content>
<Modal.Footer>
<div className="flex items-center justify-end gap-x-xsmall w-full">
<Button variant="ghost" size="small" className="w-eventButton">
Cancel
</Button>
<Button
variant="primary"
size="small"
className="w-eventButton"
onClick={handleSelectProduct}
>
Save
</Button>
</div>
</Modal.Footer>
</Modal.Body>
</Modal>
)
}

export default AddProductModal
Loading