3.0.0-alpha-4 • Published 6 months ago

@thefittingroom/shop-ui v3.0.0-alpha-4

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

The Fitting Room - Shop UI

Modal UI for The Fitting Room. Provides UI hooks to integrate into the parent UI.

Installation

npm i @thefittingroom/shop-ui

or

yarn @thefittingroom/shop-ui

Usage

import { initFittingRoom } from '@thefittingroom/shop-ui'

// Your brandId: Number
const shopId: number = 9001

// CSS Variable

export type TfrCssVariables = {
  // Colors
  brandColor?: string
  black?: string
  red?: string
  white?: string
  muted?: string
  dark?: string
  grey?: string
  lightGrey?: string

  // Main div stlyes
  mainBorderColor?: string
  mainBorderRadius?: string
  mainBorderWidth?: string
  mainBgColor?: string
  mainWidth?: string
  mainVPadding?: string
  mainHPadding?: string

  // Typography
  // All others will inherit fron mainFont if not set
  mainFont?: string
  titleFont?: string
  subtitleFont?: string
  rowFont?: string
  ctaFont?: string

  // Size Selector
  sizeSelectorTextColor?: string
  sizeSelectorFontSize?: string
  sizeSelectorFontWeight?: string
  sizeSelectorBgColor?: string
  sizeSelectorBgColorHover?: string
  sizeSelectorBgColorActive?: string
  sizeSelectorButtonHeight?: string
  sizeSelectorButtonActiveHeight?: string
  sizeSelectorButtonBorderColor?: string
  sizeSelectorButtonBorderWidth?: string
  sizeSelectorButtonRadius?: string
  sizeSelectorButtonShadow?: string
}

// UI Hooks
// These are used to hook into the lifecycle methods within the shop UI
const hooks: TfrHooks = {
  onLoading: () => {},
  onLoadingComplete: () => {},
  onError: (error: string) => {},
  onLogin: () => {},
  onLogout: () => {},
}

const cssVariables = {}

// the div id to contain the modal elements
const modalDivId: string = 'tfr-modal'

// The div id to contain the size recommendation UI
const sizeRecDivId: string = 'tfr-size-rec'

// initFittingRoom is an async function and must be awaited
const tfr = await initFittingRoom(shopId, modalDivId, sizeRecDivId, hooks, cssVariables, 'prod')

// on page nav to new product
tfr.setSku(sku)

// on user login to brand site or after initFittingRoom
// e.g. uuid, email address, username, internal database Id
tfr.setBrandUserId(brandUserId)

CSS variable defaults

:root {
  /* Colors */
  --tfr-brand-color: #209da7;
  --tfr-black: #000000;
  --tfr-red: #ff0000;
  --tfr-white: #ffffff;
  --tfr-muted: #a7a7a7;

  --tfr-dark: #121212;
  --tfr-grey: #878787;
  --tfr-light-grey: #dbdcdc;
  --tfr-dark-grey: #3f3f3f;

  /* Main */
  --tfr-main-border-color: rgba(18, 18, 18, 0.55);
  --tfr-main-border-radius: 0;
  --tfr-main-border-width: 1px;
  --tfr-main-bg-color: inherit;

  /* Spacing */
  --tfr-main-width: 440px;
  --tfr-main-v-padding: 14px;
  --tfr-main-h-padding: 20px;

  /* Typography */
  --tfr-main-font: inherit;
  --tfr-title-font: var(--tfr-main-font);
  --tfr-subtitle-font: var(--tfr-main-font);
  --tfr-row-font: var(--tfr-main-font);
  --tfr-cta-font: var(--tfr-main-font);

  /* Size Selector */
  --tfr-size-selector-text-color: var(--tfr-white);
  --tfr-size-selector-font-size: 14px;
  --tfr-size-selector-font-weight: 400;
  --tfr-size-selector-border-color: transparent;
  --tfr-size-selector-border-width: 0;
  --tfr-size-selector-bg-color: var(--tfr-grey);
  --tfr-size-selector-bg-color-hover: var(--tfr-dark-grey);
  --tfr-size-selector-bg-color-active: var(--tfr-dark);
  --tfr-size-selector-button-height: 35px;
  --tfr-size-selector-button-active-height: 45px;
  --tfr-size-selector-button-active-border-color: transparent;
  --tfr-size-selector-button-active-border-width: 0;
  --tfr-size-selector-button-radius: 8px;
  --tfr-size-selector-button-shadow: 0 4px 4px 0 rgba(0, 0, 0, 0.3);
}

Several low level methods are exposed via tfr.shop

See @thefittingroom/sdk

3.0.0-alpha-4

6 months ago

3.0.0-alpha-0

6 months ago

3.0.0-alpha-2

6 months ago

3.0.0-alpha-1

6 months ago

3.0.0-alpha-3

6 months ago

2.0.2

9 months ago

2.0.1

9 months ago

2.0.0

9 months ago

1.2.0

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.4.20

11 months ago

1.4.22

11 months ago

1.4.21

11 months ago

1.4.24

11 months ago

1.4.23

11 months ago

1.4.26

11 months ago

1.4.25

11 months ago

1.4.28

11 months ago

1.4.27

11 months ago

1.4.29

11 months ago

1.4.31

11 months ago

1.4.30

11 months ago

1.4.33

11 months ago

1.3.9

1 year ago

1.4.32

11 months ago

1.3.8

1 year ago

1.4.35

11 months ago

1.4.34

11 months ago

1.4.37

11 months ago

1.4.36

11 months ago

1.4.39

11 months ago

1.4.38

11 months ago

1.5.5

11 months ago

1.5.4

11 months ago

1.5.3

11 months ago

1.5.2

11 months ago

1.5.1

11 months ago

1.5.0

11 months ago

1.4.11

11 months ago

1.4.10

11 months ago

1.4.13

11 months ago

1.4.12

11 months ago

1.4.15

11 months ago

1.4.14

11 months ago

1.4.17

11 months ago

1.4.16

11 months ago

1.4.19

11 months ago

1.4.18

11 months ago

1.4.6

12 months ago

1.4.5

12 months ago

1.4.4

12 months ago

1.4.3

12 months ago

1.4.2

12 months ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.10

1 year ago

1.3.13

1 year ago

1.3.14

1 year ago

1.3.11

1 year ago

1.3.12

1 year ago

1.5.9

10 months ago

1.5.8

11 months ago

1.5.7

11 months ago

1.5.6

11 months ago

1.3.7

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.4.40

11 months ago

1.4.9

11 months ago

1.4.8

11 months ago

1.4.7

11 months ago

1.1.9

1 year ago

1.1.10

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.0

1 year ago

0.1.13

2 years ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.2

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago