Skip to content

Commit

Permalink
feat: add icon button (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWaldschmidt authored Apr 10, 2024
1 parent 7e8f51a commit c90549a
Show file tree
Hide file tree
Showing 12 changed files with 557 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v2.0.32

- Add `<IconButton />` component

## v2.0.31

- Adds the icons:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lob/ui-components",
"version": "2.0.31",
"version": "2.0.32",
"engines": {
"node": ">=20.2.0",
"npm": ">=10.2.0"
Expand Down
12 changes: 12 additions & 0 deletions src/components/ConditionalWrapper.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<component :is="tag" v-if="tag">
<slot />
</component>
<slot v-else />
</template>

<script setup lang="ts">
defineProps<{
tag?: string;
}>();
</script>
2 changes: 1 addition & 1 deletion src/components/Icon/svgs/BankAccount.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/components/IconButton/IconButton.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Canvas, ArgTypes, PRIMARY_STORY } from '@storybook/addon-docs';
import { AllIconButtons, Primary } from './IconButton.stories';

# IconButton

<Canvas of={AllIconButtons} />

## Props

<ArgTypes story={PRIMARY_STORY} />
119 changes: 119 additions & 0 deletions src/components/IconButton/IconButton.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { Meta, StoryFn, StoryObj } from '@storybook/vue3';
import {
IconButtonColor,
IconButtonSize,
IconButtonVariant
} from './constants';
import mdx from './IconButton.mdx';
// @ts-ignore No types from Vue file
import IconButton from './IconButton.vue';
import { IconName } from '../Icon/types';
import routeDecorator, {
routeTemplate
} from '../../../.storybook/routeDecorator';

const meta: Meta<typeof IconButton> = {
title: 'Components/IconButton',
component: IconButton,
decorators: [
routeDecorator('/', [
{
path: '/internal',
name: 'InternalLink',
component: {
template: routeTemplate('internal')
}
}
])
],
parameters: {
docs: {
page: mdx
}
},
argTypes: {
color: {
options: Object.values(IconButtonColor),
control: {
type: 'select'
},
table: {
type: {
summary: Object.values(IconButtonColor).join(' | ')
}
}
},
icon: {
options: Object.values(IconName),
control: {
type: 'select'
},
table: {
type: {
summary: Object.values(IconName).join(' | ')
}
}
},
variant: {
options: Object.values(IconButtonVariant),
control: {
type: 'select'
},
table: {
type: {
summary: Object.values(IconButtonVariant).join(' | ')
}
}
},
size: {
options: Object.values(IconButtonSize),
control: {
type: 'select'
},
table: {
type: {
summary: Object.values(IconButtonSize).join(' | ')
}
}
},
click: {
table: {
type: 'null'
}
}
}
};

export default meta;

export const Primary: StoryObj<typeof IconButton> = {
args: {
icon: IconName.ENVELOPE
}
};

export const AllIconButtons: StoryFn<typeof IconButton> = () => ({
components: { IconButton },
template: `<div class="flex flex-col gap-4 items-center">
${Object.values(IconButtonVariant)
.map(
(variant) =>
`<div class="flex gap-2">
${Object.values(IconButtonColor)
.map(
(color) =>
`<div class="flex flex-col gap-2 items-center">
${Object.values(IconButtonSize)
.map(
(size) =>
`<IconButton icon="Envelope" variant="${variant}" color="${color}" size="${size}" />`
)
.join('')}
</div>`
)
.join('')}
</div>`
)
.join('')}
</div>`
});
Loading

0 comments on commit c90549a

Please sign in to comment.