Skip to content

Commit

Permalink
Merge pull request #20 from white-label-loyalty/docs/add-component-do…
Browse files Browse the repository at this point in the history
…cumentation

Docs/add component documentation
  • Loading branch information
iamgraeme authored Nov 18, 2024
2 parents aed2380 + 1ffba28 commit cef267c
Show file tree
Hide file tree
Showing 22 changed files with 2,607 additions and 43 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy VitePress to Vercel

on:
push:
branches: ['main']
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: npm

- name: Install dependencies
run: npm ci

- name: Build
run: npm run docs:build

- name: Get Vercel Project ID
id: get-vercel-project-id
run: echo "::set-output name=VERCEL_PROJECT_ID::$(npx vercel env pull --yes 2>/dev/null | grep -oP '(?<=VERCEL_PROJECT_ID=)[^\\r\\n]*')"
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

- name: Deploy to Vercel
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ steps.get-vercel-project-id.outputs.VERCEL_PROJECT_ID }}
working-directory: docs/.vitepress/dist
vercel-args: '--prod'
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,9 @@ storybook-static/
chromatic.log

# Explicitly include the dist directory
!dist/
!dist/


# VitePress
docs/.vitepress/dist
docs/.vitepress/cache
108 changes: 72 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
## Compatibility
# WLL React SDK

This library is compatible with:
> A powerful React SDK for building customizable loyalty experiences with configurable tiles, themes, and navigation
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
[![React Support](https://img.shields.io/badge/React-18.0.0+-61DAFB?logo=react&logoColor=white)](https://reactjs.org/)
[![React Native Support](https://img.shields.io/badge/React%20Native-0.70--0.72-61DAFB?logo=react&logoColor=white)](https://reactnative.dev/)

## ✨ Features

- 🎨 **Flexible Theming** - Full control over visual styling with automatic color derivation and responsive design system
- 🧩 **Composable Tiles** - Pre-built components for rewards, points, badges, and tiers that work together seamlessly
- 🔌 **Platform Agnostic** - Bring your own navigation and network layer to integrate with any React application
- 📱 **Mobile First** - Responsive components optimized for both mobile and desktop experiences
- 🔒 **Secure by Design** - Built-in support for custom API integration through your own backend proxy
-**Easy Integration** - Simple setup with customizable configuration for navigation, theming, and API handling

## 📚 Documentation

- [Getting Started Guide](/guide/getting-started)
- [Component Library](/components/)
- [Live Storybook Demo](https://66c36701bb14ec551f38279c-ueompbfvfq.chromatic.com/)

## 🚀 Quick Start

```bash
# npm
npm install @wll/react-sdk

# yarn
yarn add @wll/react-sdk
```

## 💻 System Requirements

The SDK is compatible with:
- React: ^18.0.0
- React Native: >=0.70.0 <0.73.0

Please ensure your project's React and React Native versions fall within these ranges for optimal compatibility.
Please ensure your project meets these version requirements for optimal compatibility.

## 🤝 Contributing

## Commit Convention
We welcome contributions! This project follows the [Conventional Commits](https://www.conventionalcommits.org/) specification to ensure consistent commit messages and automated versioning.

This repository follows [Conventional Commits](https://www.conventionalcommits.org/) specification for commit messages to ensure consistent commits and automated versioning. Each commit message should be structured as follows:
### Commit Message Format

```
type(scope?): subject
Expand All @@ -20,40 +54,42 @@ type(scope?): subject
```

### Types
- `feat`: New features (e.g., `feat(auth): add Google OAuth login`)
- `fix`: Bug fixes (e.g., `fix(api): correct rate limiting logic`)
- `hotfix`: Critical bug fixes requiring immediate deployment
- `docs`: Documentation changes
- `style`: Code style changes (formatting, missing semi colons, etc)
- `refactor`: Code changes that neither fix bugs nor add features
- `perf`: Performance improvements
- `test`: Adding or updating tests
- `build`: Changes to build system or dependencies
- `ci`: Changes to CI configuration
- `chore`: Other changes that don't modify src or test files
- `revert`: Reverting previous changes
- `wip`: Work in progress

### Scope
The scope is optional and represents the section of the codebase the commit modifies (e.g., `auth`, `api`, `ui`).

### Commit Tools
We use several tools to enforce this convention:

- **Commitlint**: Checks if your commit messages meet the conventional commit format
- **Commitizen**: CLI tool to help format commit messages
- **Husky**: Git hooks to enforce commit message format

To make a commit using the interactive commit tool:
| Type | Description |
|------|-------------|
| `feat` | New features (e.g., `feat(auth): add Google OAuth login`) |
| `fix` | Bug fixes (e.g., `fix(api): correct rate limiting logic`) |
| `hotfix` | Critical bug fixes requiring immediate deployment |
| `docs` | Documentation changes |
| `style` | Code style changes (formatting, etc) |
| `refactor` | Code changes that neither fix bugs nor add features |
| `perf` | Performance improvements |
| `test` | Adding or updating tests |
| `build` | Changes to build system or dependencies |
| `ci` | Changes to CI configuration |
| `chore` | Other changes that don't modify src or test files |
| `revert` | Reverting previous changes |
| `wip` | Work in progress |

### Development Workflow

We use several tools to maintain code quality:
- **Commitlint**: Validates commit message format
- **Commitizen**: Interactive commit message formatter
- **Husky**: Git hooks for enforcing conventions

```bash
# Make a commit using the interactive tool
yarn commit
```

### Local Setup
If you're setting up the repository locally, the commit hooks will be installed automatically when you run `yarn install`. However, if you need to reinstall the hooks, you can run:

```bash
# Reinstall git hooks if needed
yarn prepare
```

This ensures that all commits follow our conventions and maintains a clean, readable git history.
## 📄 License

[License Type] - See [LICENSE](LICENSE) for more information.

## 🆘 Support

- [Documentation](link-to-docs)
- [Issues](https://github.com/white-label-loyalty/wll-react-sdk/issues)
74 changes: 74 additions & 0 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
export default {
base: '/wll-react-sdk/',
title: 'Loyalty Tiles SDK',
description:
'A flexible component library for building customizable loyalty program interfaces',
themeConfig: {
socialLinks: [
{
icon: 'github',
link: 'https://github.com/white-label-loyalty/wll-react-sdk',
},
],
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2024 White Label Loyalty',
},
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/getting-started' },
{ text: 'Components', link: '/components' },
{ text: 'Platform Integration', link: '/platform-integration' },
{
text: 'Storybook',
link: 'https://66c36701bb14ec551f38279c-ueompbfvfq.chromatic.com/',
},
],
sidebar: {
'/guide/': [
{
text: 'Introduction',
items: [
{ text: 'Getting Started', link: '/guide/getting-started' },
{ text: 'Theme', link: '/guide/theming' },
],
},
],
'/components/': [
{
text: 'Overview',
items: [{ text: 'Introduction', link: '/components/' }],
},
{
text: 'Core',
items: [
{ text: 'WllSdkProvider', link: '/components/wll-sdk-provider' },
{ text: 'Group', link: '/components/group' },
{ text: 'Section', link: '/components/section' },
],
},
{
text: 'Tiles',
items: [
{ text: 'Badge Tile', link: '/components/badge-tile' },
{ text: 'Banner Tile', link: '/components/banner-tile' },
{ text: 'Content Tile', link: '/components/content-tile' },
{ text: 'Points Tile', link: '/components/points-tile' },
{
text: 'Reward Category Tile',
link: '/components/reward-category-tile',
},
{ text: 'Reward Tile', link: '/components/reward-tile' },
{ text: 'Tier Tile', link: '/components/tier-tile' },
],
},
],
'/platform-integration/': [
{
text: 'Platform Integration',
items: [{ text: 'Overview', link: '/platform-integration/' }],
},
],
},
},
};
64 changes: 64 additions & 0 deletions docs/components/badge-tile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Badge Tile

Displays achievement badges with support for latest earned, specific badges, and multiple achievement states.

> ⚠️ **Important**: This component only supports full height tiles (`tileHeight: 'FULL'`). Half-height tiles are not supported.
## Usage

```jsx
import { BadgeTile } from '@wlloyalty/wll-react-sdk'

const tile = {
type: 'BADGE',
tileHeight: 'FULL',
configuration: {
type: 'SPECIFIC',
name: 'Top Spender',
description: 'Spent £100 on 5 Separate transactions',
artworkUrl: 'https://example.com/badge.png',
count: 1,
awardedDatePrefix: 'Awarded',
badgeNotEarnedMessage: 'Badge not earned yet',
emptyBadgeMessage: "You haven't earned any badges yet"
}
}

function MyComponent() {
return <BadgeTile tile={tile} />
}
```

## Props

| Name | Type | Required | Description |
|------|------|----------|-------------|
| tile | `Tile` | Yes | Badge tile configuration |

## Configuration Object

| Property | Type | Description |
|----------|------|-------------|
| type | 'SPECIFIC' \| 'LATEST_EARNED' | Badge display type |
| name | string | Badge name |
| description | string | Badge description |
| artworkUrl | string | Badge image URL |
| count | number | Times achieved (0 = locked) |
| awardedDatePrefix | string | Text before award date |
| badgeNotEarnedMessage | string | Message for unearned badges |
| emptyBadgeMessage | string | Message when no badges earned |

## States

- **Not Earned**: Shows lock icon (count: 0)
- **Earned Once**: Shows badge with award date
- **Multiple Earned**: Shows badge with count (e.g., "3x")
- **Latest Badge**: Special display for most recent achievement

## Composition

- `BadgeTile.Media` - Badge artwork container
- `BadgeTile.Status` - Lock icon or achievement count
- `BadgeTile.Title` - Badge name or empty state message
- `BadgeTile.Description` - Badge description
- `BadgeTile.DateEarned` - Award date or status message
57 changes: 57 additions & 0 deletions docs/components/banner-tile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Banner Tile

Displays promotional banners with an image, text content, and optional call-to-action button.

> ⚠️ **Important**: This component only supports full height tiles (`tileHeight: 'FULL'`). Half-height tiles are not supported.
## Usage

```jsx
import { BannerTile } from '@wlloyalty/wll-react-sdk'

const tile = {
type: 'BANNER',
tileHeight: 'FULL',
configuration: {
artworkUrl: 'https://example.com/banner.jpg',
title: 'Summer Sale',
description: 'Get up to 50% off on selected items!',
ctaText: 'SHOP NOW',
ctaLink: 'https://www.example.com',
ctaLinkTarget: 'SAME_FRAME'
}
}

function MyComponent() {
return <BannerTile tile={tile} />
}
```

## Props

| Name | Type | Required | Description |
|------|------|----------|-------------|
| tile | `Tile` | Yes | Banner tile configuration |

## Configuration Object

| Property | Type | Description |
|----------|------|-------------|
| artworkUrl | string | Banner image URL |
| title | string | Banner headline |
| description | string | Banner description text |
| ctaText | string | Button text (optional) |
| ctaLink | string | URL, path (/activity), or trigger (#modal-name) |
| ctaLinkTarget | 'SAME_FRAME' \| 'NEW_WINDOW' | Link target behavior |

## States

- **With CTA**: Displays banner with button
- **Without CTA**: Displays banner content only (when ctaText is empty)

## Composition

- `BannerTile.Image` - Banner image display
- `BannerTile.Title` - Banner headline
- `BannerTile.Description` - Banner description text
- `BannerTile.CTA` - Call-to-action button
Loading

0 comments on commit cef267c

Please sign in to comment.