@naptics/vue-collection
Vue Collection
Vue Collection is a collection of styled and fully functional Vue components which can easily be integrated into our projects.
Demo Page 🎆
You can take a look at all components on GitHub Pages.
Project Setup 🚧
This section shows how to create a new Vue project with the recommended tech-stack to be ready to install Vue Collection afterwards.
- Create a new vue-project with
npm init vue@latest. Add at least typescript, jsx, eslint and prettier. - Remove boilerplate code.
- Follow the instructions to install tailwind.
npm install -D tailwindcss postcss autoprefixernpx tailwindcss init- ... follow the further instructions
- Add tailwind forms with
npm install -D @tailwindcss/forms. - Add other dependencies with
npm install @heroicons/vue vue-i18n - Copy files from
.vscodeto your project. Remove.vscode/settings.jsonfile from.gitignore. Copy.prettierrcto your project. - Make sure typescript config is correct. Double check with this repo.
Installation Guide 🔨
These are the steps to add Vue Collection to an existing project. You may have to go through the steps of Project Setup and check if you have the neccesary (peer-)dependencies installed.
- Go to npmjs.com, sign in with naptics and create a new read-only classic access token.
- Add a
.npmrcfile in your repository and add the following contents.
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
- Add the created token to your environment with the key
NPM_TOKEN(e.g., by modifing~/.zshrc). - If the project also uses pipelines to build, make sure to create a second read-only token and add it to the build environment secrets.
- Install Vue Collection with
npm i @naptics/vue-collection. - Add tailwind config -> See below
- Register i18n provider -> See below
Create new components
After you have installed Vue Collection, you can start building components using the createComponent and the createView funcitions, which are exported by Vue Collection. They enforce you to only use the neccesary API provided by Vue and create components in a uniform way.
Tailwind Config
With this tailwind config file, Vue Collection works as expected. Feel free to change the default, primary and secondary colors and add whatever is needed in your project.
// tailwind.config.js
/* eslint-disable no-undef */
const colors = require('tailwindcss/colors')
const unresolvedConfig = require('tailwindcss/defaultConfig')
const resolveConfig = require('tailwindcss/resolveConfig')
const config = resolveConfig(unresolvedConfig)
const allShades = '50|100|200|300|400|500|600|700|800|900'
const usedColors = 'default|primary|secondary|green|red|yellow|blue'
const smallSizes = '1|2|3|4|5|6|7|8|9|10|11|12|14|16|18|20'
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{tsx,ts}', './node_modules/@naptics/vue-collection/**/*.js'],
safelist: [
{
pattern: new RegExp(`^(bg|text)-(${usedColors})-(${allShades})$`),
variants: ['hover'],
},
{
pattern: new RegExp(`^ring-(${usedColors})-(${allShades})$`),
variants: ['focus-visible'],
},
{
pattern: new RegExp(`^(w|h)-(${smallSizes})$`),
},
],
theme: {
extend: {
colors: {
default: colors.slate,
primary: colors.violet,
secondary: colors.fuchsia,
},
minHeight: config.theme.spacing,
},
},
plugins: [require('@tailwindcss/forms')],
}
Register i18n Provider
These are two sample files, how the i18n provider can be registered by using vue-i18n. The translation files of Vue Collection have to be added to the i18n provider in order for the Vue Collection components to work properly.
// src/i18n/index.ts
import en from './en'
import de from './de'
import { createI18n } from 'vue-i18n'
import { registerTranslationProvider } from '@naptics/vue-collection/i18n'
const i18n = createI18n({
legacy: false,
locale: 'de',
messages: {
en,
de,
},
})
registerTranslationProvider({
trsl(key, params) {
return i18n.global.t(key, params == null ? {} : params)
},
trslc(key, count, params) {
const newCount = count ?? 0
const newParams = { n: newCount, ...params }
return i18n.global.t(key, newParams, { plural: newCount })
},
})
// src/i18n/de.ts
import vueCollection from '@naptics/vue-collection/i18n/de/vue-collection.json'
const de = {
['vue-collection']: vueCollection,
// other translation files
}
export default de
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.3 | ^3.5.0 | ||
| 1.0.2 | ^3.5.0 | ||
| 1.0.1 | ^3.5.0 | ||
| 1.0.0 | ^3.5.0 | ||
| 0.3.2 | ^3.5.0 | ||
| 0.3.1 | ^3.5.0 | ||
| 0.3.0 | ^3.5.0 | ||
| 0.2.15 | ^3.2.36 | ||
| 0.2.14 | ^3.2.36 | ||
| 0.2.13 | ^3.2.36 | ||
| 0.2.12 | ^3.2.36 | ||
| 0.2.11 | ^3.2.36 | ||
| 0.2.10 | ^3.2.36 | ||
| 0.2.9 | ^3.2.36 | ||
| 0.2.8 | ^3.2.36 | ||
| 0.2.7 | ^3.2.36 | ||
| 0.2.6 | ^3.2.36 | ||
| 0.2.5 | ^3.2.36 | ||
| 0.2.4 | ^3.2.36 | ||
| 0.2.3 | ^3.2.36 | ||
| 0.2.2 | ^3.2.36 | ||
| 0.2.1 | ^3.2.36 | ||
| 0.2.0 | ^3.2.36 | ||
| 0.1.10 | ^3.2.36 | ||
| 0.1.9 | ^3.2.36 | ||
| 0.1.8 | ^3.2.36 | ||
| 0.1.7 | ^3.2.36 | ||
| 0.1.6 | ^3.2.36 | ||
| 0.1.5 | ^3.2.36 | ||
| 0.1.4 | ^3.2.36 |
Showing the latest 30 of 41. See every release on npm
Pre-releases (7)
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.0-rc.2 | ^3.5.0 | ||
| 1.0.0-rc.1 | ^3.5.0 | ||
| 1.0.0-beta.5 | ^3.5.0 | ||
| 1.0.0-beta.4 | ^3.5.0 | ||
| 1.0.0-beta.3 | ^3.5.0 | ||
| 1.0.0-beta.2 | ^3.5.0 | ||
| 1.0.0-beta.1 | ^3.5.0 |