1.2.2 • Published 1 year ago

zolastic-component-library-experiment v1.2.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Zolastic Component Library Experiment

This is a component library created for learning purposes. It includes a variety of reusable components that can be used in your React projects.

NPM

You can find this package on npm here.

GitHub

You can find the source code for this package on GitHub here.

Installation

To install the library, you can use npm:

npm install zolastic-component-library-experiment

Usage

After installation, you can import the components from the library like this:

import { Button } from 'zolastic-component-library-experiment';

Then, you can use the components in your React components:

const MyComponent = () => {
  return <Button label="Click me" />;
};

Importing Component Styles

To ensure the styling of the components in Zolastic Component Library Experiment works correctly, you need to import the provided CSS file into your project.

import "zolastic-component-library-experiment/dist/index.css";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import "zolastic-component-library-experiment/dist/index.css";

const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body className={inter.className}>{children}</body>
    </html>
  );
}

Components

Currently, the library includes the following components:

  • Button
  • Select
  • More components will be added in the future.

Select Component

Select

import React from "react";

import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "zolastic-component-library-experiment";

const SelectDemo = () => {
  return (
    <Select>
      <SelectTrigger className="w-[180px]">
        <SelectValue placeholder="Theme" />
      </SelectTrigger>
      <SelectContent>
        <SelectItem value="light">Light</SelectItem>
        <SelectItem value="dark">Dark</SelectItem>
        <SelectItem value="system">System</SelectItem>
      </SelectContent>
    </Select>
  );
};

export default SelectDemo;
ComponentDescription
SelectTriggerThe trigger component of the <Select> dropdown.
SelectValueThe component used to display the selected value.
SelectContentThe content component of the <Select> dropdown, containing selectable options.
SelectItemIndividual selectable item within the <SelectContent>.
Prop NameDescription
onValueChangeA callback function is invoked when the selected value changes. Receives the newly selected value as an argument.
defaultValueThe default value of the <Select> component.
disabledA boolean indicating whether the <Select> component is disabled.
placeholderThe placeholder text is displayed when no option is selected. (Used in the <SelectValue> component)

Select with TanStack Virtual

import React from "react";

import {
  Select,
  SelectContentTanStackVirtual,
  SelectContentTanStackVirtualItem,
  SelectTrigger,
  SelectValue,
} from "zolastic-component-library-experiment";

const SelectTanStackVirtualDemo = () => {
  const data: SelectContentTanStackVirtualItem[] = Array.from(
    { length: 15 },
    (_, i) => ({
      label: `Option ${i + 1}`,
      value: `option-${i + 1}`,
    })
  );

  return (
    <Select>
      <SelectTrigger className="w-[180px]">
        <SelectValue placeholder="Options" />
      </SelectTrigger>
      <SelectContentTanStackVirtual data={data} />
    </Select>
  );
};

export default SelectTanStackVirtualDemo;
ComponentDescription
SelectTriggerThe trigger component of the <Select> dropdown.
SelectValueThe component used to display the selected value.
SelectContentTanStackVirtualThe content component of the <Select> dropdown, containing selectable options.
Prop NameDescription
dataAn array of objects representing the options to be displayed in the <SelectContentTanStackVirtual>. Each object should have label and value properties.

MultiSelect

import React from "react";
import {
  MultiSelect,
  MultiSelectItem,
} from "zolastic-component-library-experiment";

type Props = {};

const MultiSelectDemo = (props: Props) => {
  const data: MultiSelectItem[] = Array.from({ length: 100 }, (_, i) => ({
    label: `Option ${i + 1}`,
    value: `option-${i + 1}`,
  }));

  return <MultiSelect items={data} />;
};

export default MultiSelectDemo;
Prop NameDescription
itemsAn array of objects representing the selectable items in the dropdown. Each object should have label and value properties.
selectedItemsAn optional array of objects representing the initially selected items in the dropdown.
placeholderTextThe text to display as a placeholder when no item is selected.
notFoundTextOptional text to display when no items are found in the dropdown.
badgeVariantThe variant of the badge used to display selected items. Can be one of "default", "primary", or "secondary".
badgeClassNameOptional class name to be applied to the badge component.
widthThe width of the MultiSelect component.
inputHeightThe height of the input field.
selectContentMaxHeightThe maximum height of the dropdown content.
inputScrollableA boolean indicating whether the input field should be scrollable if the content exceeds its height.
maxSelectedItemsThe maximum number of items that can be selected.
hidePlaceholderWhenSelectedA boolean indicating whether to hide the placeholder text when items are selected.
disabledA boolean indicating whether the MultiSelect component is disabled.
defaultOpenA boolean indicating whether the dropdown should be open by default.
onMaxSelectedAn optional callback function invoked when the maximum number of items is selected.
onSelectA callback function is invoked when an item is selected.
onUnselectA callback function is invoked when an item is unselected.
onOpenA callback function is invoked when the dropdown is opened or closed.

Tag Component

Tag

import React from "react";
import { Tag } from "zolastic-component-library-experiment";

const TagDemo = () => {
  return <Tag>Tag</Tag>;
};

export default TagDemo;
Prop NameDescription
classNameAdditional CSS classes to apply to the tag container.
variantThe variant of the tag. Can be one of "default", "primary", or "secondary".
closeableWhether the Tag can be closed. Default is false. If true, a close button will be displayed.
onCloseCallback when the Tag is closed.
iconIcon to display alongside the Tag text. Default is null.
disabledWhether the Tag is disabled. Default is false.
borderWhether the Tag has a border. Default is true.

Checkable Tag

import React from "react";
import { CheckableTag } from "zolastic-component-library-experiment";

const CheckableTagDemo = () => {
  return <CheckableTag>CheckableTag</CheckableTag>;
};

export default CheckableTagDemo;
Prop NameDescription
classNameAdditional CSS classes to apply to the tag container.
variantThe variant of the tag. Can be one of "default", "primary", or "secondary".
checkedWhether the Tag is checked by default. Default is false.
checkedBackgroundColorBackground color when Tag is checked. Default is "#DDD2F0".
checkedTextColorText color when Tag is checked. Default is "#482384".
onClickTagCallback when the Tag is clicked.
closeableWhether the Tag can be closed. Default is false. If true, a close button will be displayed.
onCloseCallback when the Tag is closed.
iconIcon to display alongside the Tag text. Default is null.
disabledWhether the Tag is disabled. Default is false.
borderWhether the Tag has a border. Default is true.

Contributing

As this is a learning project, contributions are not currently being accepted. However, you're welcome to fork the project and make your own modifications.

1.2.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.0

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago