Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@justeattakeaway/pie-button

Package Overview
Dependencies
Maintainers
8
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@justeattakeaway/pie-button

PIE design system button built using web components

  • 0.12.0
  • npm
  • Socket score

Version published
Weekly downloads
371
decreased by-12.29%
Maintainers
8
Weekly downloads
 
Created
Source

GitHub Workflow Status

Table of Contents

  1. Introduction
  2. Local Development
  3. Props
  4. Events
  5. TypeScript Enum Exports
  6. Testing

pie-button

pie-button is a Web Component built using the Lit library. It offers a simple and accessible button component for web applications. This component can be easily integrated into various frontend frameworks and customized through a set of properties. For TypeScript projects, it also provides exported enums for type safety and autocompletion.

Local development

Install dependencies at the root

yarn

Navigate to this folder, compile with TypeScript and build with Vite

cd packages/components/pie-button
yarn build

compile using Vite (auto-compiles dist on save)

yarn watch

Local dev server using Vite (with hot module reloading)

yarn dev

Props

PropertyTypeDefaultDescription
sizeStringBUTTON_SIZE.MEDIUMSize of the button, one of BUTTON_SIZE enum values (TypeScript Enum) or a raw string value such as 'large'
typeStringBUTTON_TYPE.SUBMITType of the button, one of BUTTON_TYPE enum values (TypeScript Enum) or a raw string value such as 'submit'
variantStringBUTTON_VARIANT.PRIMARYVariant of the button, one of BUTTON_VARIANT enum values (TypeScript Enum) or a raw string value such as 'primary'
disabledBooleanfalseIf true, disables the button.
isFullWidthBooleanfalseIf true, sets the button width to 100% of it's container.

Events

This component does not use any custom event handlers. In order to add event listening to this component, you can treat it like a native HTML element in your application.

For example, to add a click handler in various templates:

HTML

<!-- Other attributes omitted for clarity -->
<pie-button onclick="e => console.log(e)">Click me!</pie-button>

Vue templates (using Nuxt 3)

<!-- Other attributes omitted for clarity -->
<pie-button @click="handleClick">Click me!</pie-button>

React templates (using Next 13)

<!-- Other attributes omitted for clarity -->
<PieButton onClick={handleClick}>increment</PieButton>

TypeScript Enum Exports

For TypeScript projects, we export three enums related to button properties: BUTTON_SIZE, BUTTON_TYPE, and BUTTON_VARIANT. You can import and use these enums to set the corresponding property values for the pie-button component. This ensures better type safety and autocompletion in your project.

Here's an example of how to import and use the enums in a TypeScript project:

import { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT } from '@justeattakeaway/pie-button';

// Using the enums to set property values
const myButtonSize = BUTTON_SIZE.LARGE;
const myButtonType = BUTTON_TYPE.RESET;
const myButtonVariant = BUTTON_VARIANT.SECONDARY;

In your markup or JSX, you can then use these variables to set the properties for the pie-button component:

<PieButton size={myButtonSize} type={myButtonType} variant={myButtonVariant}>Click me!</PieButton>

Testing

Browser tests

Run at the root of the monorepo:

yarn test:browsers --filter=pie-button

Visual tests

Run at the root of the monorepo:

yarn test:visual --filter=pie-button

FAQs

Package last updated on 12 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc