A comprehensive Vue.js component library for the University of York Students' Union website. This repository serves as both a development environment and component distribution system, providing reusable UI components built as Vue Custom Elements that can be used across the York SU digital ecosystem.
- Vue Custom Elements: Components exported as web components for maximum compatibility
- Storybook Integration: Interactive component documentation and testing environment
- Automated Deployment: Continuous deployment to Cloudflare R2 for seamless integration
- Design System: Consistent UI components following York SU branding guidelines
- Accessibility First: Built with accessibility standards in mind
- Node.js (version 22 LTS)
- npm (comes with Node.js)
-
Clone the repository:
git clone https://github.com/YUSU-Dev/Vue-3-Components.git cd Vue-3-Components -
Install dependencies:
npm ci
-
Start the development environment:
npm run storybook
This will launch Storybook at
http://localhost:6006where you can view and interact with all components.
npm run storybook- Start Storybook development servernpm run dev- Start local development servernpm run build- Build production-ready componentsnpm run build-css- Build Tailwind CSS stylesnpm run new -- -c component-name- Generate a new componentnpm run new -- -p page-name- Generate a new pagenpm run test-storybook- Run Storybook tests
src/
├── components/ # Reusable UI components
│ ├── button/
│ │ ├── button.ce.vue # Vue component file
│ │ ├── button.component.js # Component registration
│ │ └── button.stories.js # Storybook stories
│ └── [other components]/
├── pages/ # Full page components
├── docs/ # Documentation files
└── _common/ # Shared utilities and helpers
Use our CLI tool to quickly scaffold a new component:
npm run new -- -c my-componentThis creates:
my-component.ce.vue- The Vue componentmy-component.component.js- Component registrationmy-component.stories.js- Storybook stories
- Use kebab-case for all file and directory names
- Vue files must end with
.ce.vue(Custom Element) - Follow the Options API pattern for Vue components
- Include comprehensive Storybook stories for each component
- Ensure components are accessible and follow WCAG guidelines
<!-- button.ce.vue -->
<template>
<button class="btn" :class="variant" @click="handleClick">
<slot></slot>
</button>
</template>
<script>
export default {
name: "Button",
props: {
variant: {
type: String,
default: "primary",
validator: (value) => ["primary", "secondary"].includes(value),
},
},
methods: {
handleClick(event) {
this.$emit("click", event);
},
},
};
</script>Components are automatically deployed to https://assets.yorksu.org when changes are merged to the main branch.
-
Include the component script:
<script src="https://assets.yorksu.org/components/button.js"></script>
-
Use the component in your HTML:
<york-su-button variant="primary">Click me</york-su-button>
For detailed integration instructions, visit our Storybook documentation.
- Vue 3 with Options API
- Tailwind CSS for styling
- Storybook for component development and documentation
- ESLint & Prettier for code quality
- Rollup for bundling
- Husky for git hooks
- Storybook - Interactive component documentation
- Contributing Guide - Technical contribution guidelines
- Style Guide - Design system guidelines
We welcome contributions! Please see our Contributing Guide for detailed instructions.
- Check existing issues
- Fork the repository
- Create a feature branch
- Make your changes
- Add/update tests and stories
- Submit a pull request
- Use npm for dependency management
- Write Vue components using the Options API
- Export components as Custom Elements
- Follow kebab-case naming conventions
- Include comprehensive Storybook stories
- Ensure accessibility compliance
This component library aims to:
- Provide consistent UI components across York SU digital properties
- Improve development efficiency through reusable components
- Maintain high accessibility and usability standards
- Enable rapid prototyping and development
- Foster collaboration between teams
Storybook won't start:
- Ensure Node.js version 22 LTS is installed
- Clear npm cache:
npm cache clean --force - Delete
node_modulesand runnpm ci
Components not updating:
- Check if you're editing the
.ce.vuefile (not.vue) - Ensure component is properly registered in the
.component.jsfile - Restart Storybook after making changes
Build failures:
- Check ESLint errors:
npx eslint src/ - Verify all imports are correct
- Ensure Tailwind classes are valid
- 🎮 SU Digital CoP Discord
- 📧 Email: it@yorksu.org
- 🐛 GitHub Issues
If you've found a vulnerability, we want to know so that we can fix it. Our security policy tells you how to do this.
Copyright © 2024 University of York Students' Union
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License.