1.1.7 • Published 26 days ago

vinyl-component-blocks v1.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
26 days ago

Introduction

Offering a set of commonly used components that are designed to be easy to use, highly customizable, and visually appealing. Whether you're building a simple login form, a complex dashboard interface or seeking inspiration while building components in your development process, Vinyl Component(VC) Blocks has the basic components you need to create a polished user experience.

Installation and Setup 🧱

You can install Vinyl Component Blocks via npm or yarn:

npm install vinyl-component-blocks

or

yarn add vinyl-component-blocks

Usage

Once installed, you can import the components you need from Vinyl Component Blocks and use them in your React application:

import React from "react";
import {
  Button,
  FormControl,
  Link,
  Search,
  Select,
  Skeleton,
  Spinner,
  TextInput,
  Typography,
  Avatar,
  Card,
  Modal,
  Header,
} from "vinyl-component-blocks";

Demo Example Combining Components

import React from "react";
import { Button, Card, Avatar } from "vinyl-component-blocks";

const DemoComponent = () => (
  <div>
    <Card backgroundColor="#f0f0f0" padding="20px">
      <Avatar imageSrc="https://example.com/avatar.jpg" />
      <h2>John Doe</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
      <Button type="primary" size="medium">
        Read More
      </Button>
    </Card>
  </div>
);

export default DemoComponent;
  • Providing a hands-on experience with the Vinyl Component Blocks library, showcasing the versatility and functionality of each component. Key components here include the Header and Login UI components.
import React from "react";
import { Button, Card, Avatar, Header, Login } from "vinyl-component-blocks";

const DemoComponent = () => (
  <div>
    <Header
      user={{ name: "John Doe" }}
      onLogout={() => console.log("Logged out")}
    />
    <Card backgroundColor="#f0f0f0" padding="20px">
      <Avatar imageSrc="https://example.com/avatar.jpg" />
      <h2>John Doe</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
      <Button type="primary" size="medium">
        Read More
      </Button>
    </Card>
    <Login
      onLogin={() => console.log("Logged in")}
      onCreateAccount={() => console.log("Creating account")}
    />
  </div>
);

export default DemoComponent;

Components

Button

PropTypeDescription
typestringButton type (default, danger, ghost, secondary )
sizestringButton size (default, large, small)
disabledbooleanDisable button
onClickfunctionClick event handler
childrenReactNodeButton content
iconElementTypeIcon component to display alongside the button text
classNamestringAdditional CSS classes for styling
loadingbooleanSpecify whether the button should display a loading spinner
hrefstringURL for the button if it should act as a link
asElementTypeHTML element type for the button
tostringDestination path for the link if using the 'as' prop
...restanyAdditional props for customization

FormControl

PropTypeDescription
labelstringLabel for the form control
htmlForstringID of the form control element
errorstringError message to display
hintstringHint message to display
disabledbooleanDisable the form control
classNamestringAdditional CSS classes for styling
childrenReactNodeForm control element
onBlurfunctionBlur event handler
onFocusfunctionFocus event handler
forceLabelbooleanForce label to always show
...restanyAdditional props for customization

Link

PropTypeDescription
disabledbooleanDisable the link
classNamestringAdditional CSS classes for styling
childrenReactNodeLink text
asElementTypeHTML element type (default is a)
hrefstringLink URL
...restanyAdditional props for customization

Search

PropTypeDescription
classNamestringAdditional CSS classes for styling
sizeComponentSizeSize of the search input (default, small, large)
widthstringWidth of the search input
valuestringCurrent value of the search input
onChangefunctionChange event handler for the search input
placeholderstringPlaceholder text for the search input

Select

PropTypeDescription
classNamestringAdditional CSS classes for styling
sizeComponentSizeSize of the select input (default, small, large)
disabledbooleanDisable the select input
errorbooleanIndicate error state
widthstringWidth of the select input
optionSelectOptionSelected option
listOptionsSelectOption[]Array of options for the select input
onChangefunctionChange event handler for the select input
placeholderstringPlaceholder text for the select input

Skeleton

PropTypeDescription
widthnumberWidth of the skeleton element
heightnumberHeight of the skeleton element
classNamestringAdditional CSS classes for styling
borderRadiusstringBorder radius of the skeleton element

Spinner

PropTypeDescription
sizenumberSize of the spinner
classNamestringAdditional CSS classes for styling
lightbooleanUse light spinner variant

TextInput

PropTypeDescription
iconElementTypeIcon component to display
sizeComponentSizeSize of the input (default, small, large)
disabledbooleanDisable the input
errorbooleanIndicate error state
valuestringCurrent value of the input
onChangefunctionChange event handler for the input
placeholderstringPlaceholder text for the input
widthstringWidth of the input
readonlybooleanMake the input read-only
clearablebooleanAllow clearing the input
...restanyAdditional props for customization

Typography

PropTypeDescription
variantstringTypography variant (h1, h2, h3)
alignstringText alignment (center, right, left)
classNamestringAdditional CSS classes for styling
childrenReactNodeText content

Avatar

PropTypeDescription
imageSrcstringSource URL for the avatar image

Card

PropTypeDescription
backgroundColorstringBackground color of the card
childrenReactNodeContent to be displayed within the card
paddingstringPadding around the content inside the card

Modal

PropTypeDescription
childrenReactNodeContent to be displayed within the modal

Header

PropTypeDescription
userUserUser object
onLoginfunctionEvent handler for login action
onLogoutfunctionEvent handler for logout action
onCreateAccountfunctionEvent handler for create account action

Login

PropTypeDescription
onSubmitfunctionEvent handler for form submission
initialValuesobjectInitial values for the form fields
loadingbooleanSpecify whether to display loading state
registerLinkstringLink for user registration

External Resources and Dependencies 🌐

The Vinyl Component Blocks library relies on the following external resources and dependencies:

  • Styled Components: Utilized for customizable styling of components. CSS-in-JS library.

  • React: Serves as the core of the Vinyl Component Blocks, providing the necessary infrastructure for building user interfaces in JavaScript.

  • TypeScript: Vinyl Component Blocks is super strictly typed. TypeScript as a strict syntactical superset of JavaScript adds static typing to the library. It enhances developer productivity and code quality.

  • Email Validator: Used for validating emails, for the input-component most specifically. Email Validator is a dependency that helps ensure that the entered email addresses conform to standard email format rules, enhancing the reliability and accuracy of user input validation.

Demo Examples 🛠️

Customizing TextInput Component

import React from "react";
import { TextInput } from "vinyl-component-blocks";

const CustomTextInput = () => (
  <TextInput
    className="custom-text-input"
    icon={YourIconComponent}
    size="large"
    disabled={false}
    error={false}
    value="Hello"
    onChange={(e) => console.log(e.target.value)}
    placeholder="Enter text here"
    width="200px"
    readonly={false}
    clearable={true}
  />
);

export default CustomTextInput;

Demo Example, Simple Login UI

import React from "react";
import { Header, Login } from "vinyl-component-blocks";

const HeaderWithLogin = () => (
  <div>
    <Header
      user={{ name: "John Doe" }}
      onLogout={() => console.log("Logged out")}
    />
    <Login
      onLogin={() => console.log("Logged in")}
      onCreateAccount={() => console.log("Creating account")}
    />
  </div>
);

export default HeaderWithLogin;

Customizing Components with Custom CSS Styles ✨

Customizing components with custom CSS styles allows you to tailor the appearance of UI components to match the specific design requirements of your project. Applying custom CSS classes to components, you can override default styles and apply unique visual enhancements. This approach offers flexibility and control over the presentation of components.

Customizing Card Component

import React from "react";
import { Card } from "vinyl-component-blocks";
import "./custom-styles.css";

const CustomCard = () => (
  <Card
    backgroundColor="#f0f0f0"
    padding="20px"
    className="custom-card" // Custom CSS class for styling
  >
    <h2>This is a Custom Card</h2>
    <p>
      Stop reinventing the wheel! Our well-documented component library empowers
      you to concentrate on building unique features and functionalities.
    </p>
  </Card>
);

export default CustomCard;

Customizing TextInput Component

import React from "react";
import { TextInput } from "vinyl-component-blocks";
import "./custom-styles.css";

const CustomTextInput = () => (
  <TextInput
    className="custom-text-input" // Custom CSS class for styling
    icon={YourIconComponent}
    size="large"
    disabled={false}
    error={false}
    value="Hello"
    onChange={(e) => console.log(e.target.value)}
    placeholder="Enter text here"
    width="200px"
    readonly={false}
    clearable={true}
  />
);

export default CustomTextInput;

In the custom-styles.css file:

/* custom-styles.css */
.custom-card {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
}

.custom-text-input {
  border: 2px solid #cccccc;
  border-radius: 8px;
}

Contributing

Adding New Components

Contributions from developers who feel the need to expand the library with new components or features. Whether you've identified a potential component, have an idea for a new feature, or want to enhance existing functionality, your contributions are valuable to the community.

If you find something that piques your interest or if the project has inspired you, feel free to contribute by submitting pull requests(PRs). Your contributions help improve the library for everyone. Don't forget to leave a star ⭐ on GitHub to show your support!

Conclusion

Vinyl Component Blocks offers a comprehensive collection of UI components that are easy to use and highly customizable. Say goodbye to design inconsistencies.

So, stop reinventing the wheel! Our well-documented component library empowers you to create, clone and build unique component features and functionalities to your taste.

Stop repeating work! Install, call, use, modify. npm install vinyl-component-blocks.

1.1.7

26 days ago

1.1.6

28 days ago

1.1.5

28 days ago

1.1.4

28 days ago

1.1.3

28 days ago

1.1.1

1 month ago

1.0.19

1 month ago

1.1.0

1 month ago

1.0.18

1 month ago

1.0.17

1 month ago

1.0.16

1 month ago

1.1.2

1 month ago

1.0.15

1 month ago

1.0.14

1 month ago

1.0.9

1 month ago

1.0.8

1 month ago

1.0.7

1 month ago

1.0.6

1 month ago

1.0.5

1 month ago

1.0.4

1 month ago

1.0.11

1 month ago

1.0.10

1 month ago

1.0.13

1 month ago

1.0.12

1 month ago

1.0.2

1 month ago