This is the implementation of Fifteen’s design system in Vue3 + Composition API + Typescript.
It is based on vue
, @vueuse/core
and vee-validate
which are made external.
It is also based on vue3-popper
which is built and bundled in the lib.
npm install @fifteen/design-system-vue
or
yarn add @fifteen/design-system-vue
You can use directly the design system components, composables, utils, constants and types exported by the lib, e.g.:
import { FButton, FButtonProps, useFBreakpoints, colorDesignTokens, Color } from '@fifteen/design-system-vue';
You also need to add the lib CSS to your project.
import '@fifteen/design-system-vue/style.css';
If you want to use the library with Fifteen’s style, you also need to import the built-in theme CSS:
import '@fifteen/design-system-vue/theme.css';
Alternatively, if you want to customize the theme, you can look for all the CSS variables that are exposed in @fifteen/design-system-vue/theme.css
and declare yours.
If you want to use any component that relies on icons (FIcon
, FFlagIcon
or FCreditCardIcon
), you must instanciate and use the FDS plugin in your app, and import and register the icons you need. Thus you will benefit from tree-shaking !
// main.ts
import { createApp } from 'vue';
import { createFds } from '@fifteen/design-system-vue';
import { /* icon names */ } from '@fifteen/design-system-vue/icons';
import { /* flag icons names */ } from '@fifteen/design-system-vue/flag-icons';
import { /* credit card icons names */ } from '@fifteen/design-system-vue/credit-card-icons';
const app = createApp({ /* Vue app config */});
const fds = createFds({
icons: { /* icons registration */ },
flagIcons: { /* flags icons registration */ },
creditCardIcons: { /* credit card icons registration */ },
});
app.use(fds);
Alternately, you can import all the icons directly in your app and register them, but this it not the recommended way as you cannot benefit from tree-shaking;
import * as icons from '@fifteen/design-system-vue/icons';
import * as flagIcons from '@fifteen/design-system-vue/flag-icons';
import * as creditCardIcons from '@fifteen/design-system-vue/credit-card-icons';
const fds = createFds({
icons,
flagIcons,
creditCardIcons,
});
app.use(fds);
You can also import and use the svg markup direcly in an other context.
The lib ships two resolvers for auto-importing the components, and the composables and utils with Vite. They are based on unplugin-auto-import and unplugin-vue-components, and can be used with the vite plugins exposed by these packages:
// vite.config.ts
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import {
FifteenAutoImportsResolver,
FifteenComponentsResolver,
} from '@fifteen/design-system-vue/resolvers';
export default {
plugins: [
AutoImport({
resolvers: [FifteenAutoImportsResolver()],
}),
Components({
resolvers: [FifteenComponentsResolver()],
}),
],
};
The lib also ships Stylus helpers that can be very useful when authoring components. You must import @fifteen/design-system-vue/styles/components.styl
in the component’s style tag when you need them.
An other systematic way is to enable them for all components using vite config:
// vite.config.ts
export default {
css: {
preprocessorOptions: {
stylus: {
imports: ['@fifteen/design-system-vue/styles/components.styl'],
},
},
},
};
Available helpers are: Sizes:
rem(value)
converts a value in pixel into rem (value
can be unitless)
Fonts:
use-font(name)
applies font style from its name.name
can bebigger-(1|2|3|4) | heading-(1|2|3|4|5|6) | subtitle-(1|2) | body-(1|2) | button | caption | overline
clamped-fluid-size(xmin, ymin, xmax, ymax)
returns a clamped size, interpolated between two breakpointsxmin
andxmax
(must be unitless pixel values or CSS vars).
Colors:
bg-color-transition()
applies a transition to the background colorbg-color(name)
applies a background color based on a color nametext-color-transition()
applies a transition to the text colortext-color(name)
applies a text color based on a color name (also sets child svgpath
fill property) Colorname
can be all the ones defined in lib’scolorDesignTokens
array.
Elevations:
elevation-transition()
applies a transition to the elevation (box-shadow and background color)elevation(value)
applies an elevation wherevalue
can be1
to6
.elevation-light(value)
applies a light elevation wherevalue
can be1
to6
.
Media queries:
media-down(breakpoint)
media-up(breakpoint)
media-between(breakpoint)
which takes a breakpoint name as argument:'xxs' | 'xs' | 'sm' | 'md' | 'lg'
. These mixins must be called with+
prefix, e.g.:
+media-down('xs')
// style for screens smaller than xs
Others:
scrollbars(thumbColor, trackColor)
to add custom scrollbar stylemerge-transition
andmerge-will-change
to apply several transitions on the same element
The lib exposes some validation rules under @fifteen/design-system-vue/rules
folder, which are mainly picked from the @vee-validate/rules
library. In addition, some validation rules are included:
phone
: validates a phone numbermask
: validates a string regarding to a mask passed as parameter
If you want to develop the library, you can clone the repository and install the dependencies using yarn:
yarn install
Install also the husky hooks by running:
yarn husky
Then you run yarn sb
(or yarn dev
which is an alias) and Storybook will launch with the components stories on port 3003.
After having created a new component or modifying an existing one, must create or update the corresponding story.
To create a new release as an npm
package, you just need to increment the version in package.json
and run yarn release
.