Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Chrome Tests

on: [push]
on:
push:
workflow_call:

jobs:
cypress-ct:
Expand All @@ -15,8 +17,6 @@ jobs:
id: pnpm-install
with:
version: 8
run_install: false
- name: Install dependencies
run: pnpm install
run_install: true
- name: Chrome tests
run: pnpm run test:chrome
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Firefox Tests

on: [push]
on:
push:
workflow_call:

jobs:
cypress-ct:
Expand All @@ -15,8 +17,6 @@ jobs:
id: pnpm-install
with:
version: 8
run_install: false
- name: Install dependencies
run: pnpm install
run_install: true
- name: Firefox tests
run: pnpm run test:firefox
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish to NPM

on:
push:
tags: ['v*']
workflow_dispatch:

jobs:
chrome-tests:
uses: ./.github/workflows/chrome-tests.yml
firefox-tests:
uses: ./.github/workflows/firefox-tests.yml
publish:
needs: [chrome-tests, firefox-tests]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '19.x'
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: true
- name: Build
run: pnpm build
- name: Pack
run: rm -rf *.tgz && npm pack
- name: Publish
run: npm publish *.tgz --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22 changes: 0 additions & 22 deletions .github/workflows/webkit.yml

This file was deleted.

36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ Check out my other packages for Vue 3:
> _Fully-featured notification system for Vue and Nuxt._
> [Visit repo ➔ ](https://github.com/smastrom/notivue)

> 🔥 **Vue Use Fixed Header**
> _Turn your boring fixed header into a smart one with one line of code._
> [Visit repo ➔ ](https://github.com/smastrom/vue-use-fixed-header)

> 👌 **Vue Use Active Scroll**
> _Accurate TOC/sidebar links without compromises._
> [Visit repo ➔ ](https://github.com/smastrom/vue-use-active-scroll)
Expand All @@ -27,9 +23,10 @@ Check out my other packages for Vue 3:
## Installation

```shell
npm i -S vue-collapsed
npm i vue-collapsed
# yarn add vue-collapsed
# pnpm add vue-collapsed
# bun add vue-collapsed
```

## Props
Expand Down Expand Up @@ -63,7 +60,7 @@ const isExpanded = ref(false)
<button @click="isExpanded = !isExpanded">Trigger</button>

<Collapse :when="isExpanded">
<p>This is a paragraph.</p>
<p>{{ 'Collapsed '.repeat(100) }}</p>
</Collapse>
</template>
```
Expand All @@ -84,7 +81,7 @@ If you prefer to use a custom duration or easing, add a class to Collapse that t

```vue
<Collapse :when="isExpanded" class="v-collapse">
<p>This is a paragraph.</p>
<p>{{ 'Collapsed '.repeat(100) }}</p>
</Collapse>
```

Expand All @@ -95,10 +92,6 @@ If you prefer to use a custom duration or easing, add a class to Collapse that t
}
```

:bulb: Use [calc()](https://developer.mozilla.org/en-US/docs/Web/CSS/calc) to control the speed while keeping the ratio, _e.g. `calc(var(--vc-auto-duration) * 0.75)`_.

:bulb: Find a full list of easings at [easings.net](https://easings.net).

### Multiple transitions

To transition other properties use the attribute `data-collapse`:
Expand All @@ -111,7 +104,9 @@ To transition other properties use the attribute `data-collapse`:
```css
.v-collapse {
--dur-easing: var(--vc-auto-duration) cubic-bezier(0.33, 1, 0.68, 1);
transition: height var(--dur-easing), opacity var(--dur-easing);
transition:
height var(--dur-easing),
opacity var(--dur-easing);
}

.v-collapse[data-collapse='expanded'],
Expand Down Expand Up @@ -141,7 +136,7 @@ Above values can also be accessed using `v-slot`:

```vue
<Collapse :when="isExpanded" class="v-collapse" v-slot="{ state }">
{{ state === 'collapsing' ? 'Collapsing the content...' : null }}
{{ state === 'collapsing' ? 'Collapsing content...' : null }}
</Collapse>
```

Expand Down Expand Up @@ -212,16 +207,19 @@ import { Collapse } from 'vue-collapsed'

const isExpanded = ref(false)

const TOGGLE_ID = 'toggle-id'
const COLLAPSE_ID = 'collapse-id'

const toggleAttrs = computed(() => ({
id: 'toggle-id',
'aria-controls': 'collapse-id',
id: TOGGLE_ID,
'aria-controls': COLLAPSE_ID,
'aria-expanded': isExpanded.value
}))

const collapseAttrs = {
role: 'region',
id: 'collapse-id',
'aria-labelledby': 'toggle-id'
id: COLLAPSE_ID,
'aria-labelledby': TOGGLE_ID
}

function handleCollapse() {
Expand All @@ -233,7 +231,7 @@ function handleCollapse() {
<div>
<button v-bind="toggleAttrs" @click="handleCollapse">This a panel.</button>
<Collapse v-bind="collapseAttrs" :when="isExpanded">
<p>This is a paragraph.</p>
<p>{{ 'Collapsed '.repeat(100) }}</p>
</Collapse>
</div>
</template>
Expand All @@ -244,7 +242,7 @@ function handleCollapse() {
```vue
<template>
<Collapse :when="isExpanded" class="instant-collapse">
<p>This is a paragraph.</p>
<p>{{ 'Collapsed '.repeat(100) }}</p>
</Collapse>
</template>

Expand Down
1 change: 0 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { defineConfig } from 'cypress'
export default defineConfig({
component: {
video: false,
experimentalWebKitSupport: true,
devServer: {
framework: 'vue',
bundler: 'vite',
Expand Down
11 changes: 7 additions & 4 deletions demo/SingleCollapse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ function handleCollapse() {
* https://www.w3.org/WAI/ARIA/apg/example-index/accordion/accordion
*/

const TOGGLE_ID = 'toggle'
const COLLAPSE_ID = 'collapse'

const toggleAttrs = computed(() => ({
id: 'toggle',
id: TOGGLE_ID,
'aria-controls': COLLAPSE_ID,
'aria-expanded': isExpanded.value,
'aria-controls': 'collapse',
}))

const collapseAttrs = {
'aria-labelledby': 'toggle',
id: 'collapse',
'aria-labelledby': TOGGLE_ID,
id: COLLAPSE_ID,
role: 'region',
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion demo/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Collapse from '../src/Collapse.vue'
import { Collapse } from '../dist'
import { createApp } from 'vue'
import App from './App.vue'

Expand Down
42 changes: 19 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-collapsed",
"version": "1.2.8",
"version": "1.2.9",
"private": false,
"description": "Dynamic CSS height transition from any to auto and vice versa for Vue 3. Accordion ready.",
"keywords": [
Expand Down Expand Up @@ -39,37 +39,33 @@
"dist/*"
],
"scripts": {
"build": "rimraf dist && vite build",
"build": "vite build",
"postbuild": "pnpm pack",
"build:app": "vite build --mode app",
"dev": "vite",
"preview": "vite build --mode app && vite preview",
"build:app": "vite build && vite build --mode app",
"dev": "concurrently \"vite\" \"vite build --watch\"",
"preview": "vite build:app && vite preview",
"prepare": "husky install",
"test:chrome": "cypress run --component --browser chrome",
"test:firefox": "cypress run --component --browser firefox",
"test:webkit": "cypress run --component --browser webkit",
"test": "pnpm test:chrome && pnpm test:firefox && pnpm test:webkit",
"test:gui": "cypress open --component"
"test:chrome": "pnpm build && cypress run --component --browser chrome",
"test:firefox": "pnpm build && cypress run --component --browser firefox",
"test:gui": "concurrently \"vite build --watch\" \"cypress open --component\""
},
"lint-staged": {
"*.{ts,vue,md}": "prettier --write"
},
"devDependencies": {
"@babel/types": "^7.22.10",
"@rollup/plugin-terser": "^0.4.3",
"@types/node": "^18.17.6",
"@vitejs/plugin-vue": "^4.3.1",
"cypress": "^12.17.4",
"@rollup/plugin-terser": "^0.4.4",
"@types/node": "^20.8.7",
"@vitejs/plugin-vue": "^4.4.0",
"concurrently": "^8.2.2",
"cypress": "^13.3.2",
"cypress-wait-frames": "^0.9.4",
"husky": "^8.0.3",
"lint-staged": "^13.3.0",
"playwright-webkit": "^1.37.1",
"prettier": "^2.8.8",
"rimraf": "^4.4.1",
"typescript": "^4.9.5",
"vite": "^4.4.9",
"vite-plugin-dts": "^1.7.3",
"lint-staged": "^15.0.2",
"prettier": "^3.0.3",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vite-plugin-dts": "^3.6.0",
"vue": "^3.3.4",
"vue-tsc": "^1.8.8"
"vue-tsc": "^1.8.19"
}
}
Loading