Skip to content

Commit

Permalink
Upgrade to Stimulus 3.0 (#102)
Browse files Browse the repository at this point in the history
* Upgrade to Stimulus 3.0

Also updates docs to use ESM and importmaps

* Fix tests

* Remove babel

* Update dependencies

* Use from CDN

* Update tests for Jest 27
  • Loading branch information
excid3 authored Sep 25, 2021
1 parent 6750d17 commit 537cd5d
Show file tree
Hide file tree
Showing 27 changed files with 11,444 additions and 12,262 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14' ]
node: ['14', '16']
name: Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: yarn install
- run: yarn test
- run: npm install
- run: npm run test
13 changes: 11 additions & 2 deletions __tests__/dropdown_test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Application, Controller } from "stimulus"
/**
* @jest-environment jsdom
*/

import { Application, Controller } from "@hotwired/stimulus"
import Dropdown from 'dropdown'

describe("DropdownController", () => {

describe("with active target specified", () => {
beforeEach(() => {
jest.useFakeTimers()
jest.useFakeTimers('legacy');

document.body.innerHTML = `
<div class="relative"
data-dropdown-active-target='#active_target' data-controller="dropdown"
Expand Down Expand Up @@ -33,6 +38,10 @@ describe("DropdownController", () => {
application.register("dropdown", Dropdown);
});

afterEach(() => {
jest.useRealTimers();
});

it('applies visible class to target ', async () => {
const target = document.querySelector('[data-dropdown-target="menu"]');
const action = document.querySelector('[data-action]');
Expand Down
6 changes: 5 additions & 1 deletion __tests__/popover_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Application, Controller } from "stimulus";
/**
* @jest-environment jsdom
*/

import { Application, Controller } from "@hotwired/stimulus";
import Popover from "popover";

describe("PopoverController", () => {
Expand Down
6 changes: 5 additions & 1 deletion __tests__/slideover_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Application, Controller } from "stimulus"
/**
* @jest-environment jsdom
*/

import { Application, Controller } from "@hotwired/stimulus"
import Slideover from 'slideover'

const fs = require('fs');
Expand Down
6 changes: 5 additions & 1 deletion __tests__/tabs_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Application, Controller } from "stimulus";
/**
* @jest-environment jsdom
*/

import { Application, Controller } from "@hotwired/stimulus";
import Tabs from "tabs";

const fs = require('fs');
Expand Down
6 changes: 5 additions & 1 deletion __tests__/toggle_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Application, Controller } from 'stimulus'
/**
* @jest-environment jsdom
*/

import { Application, Controller } from '@hotwired/stimulus'
import Toggle from 'toggle'

describe('ToggleController', () => {
Expand Down
2 changes: 1 addition & 1 deletion dist/tailwindcss-stimulus-components.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tailwindcss-stimulus-components.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tailwindcss-stimulus-components.m.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tailwindcss-stimulus-components.m.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tailwindcss-stimulus-components.modern.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tailwindcss-stimulus-components.modern.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tailwindcss-stimulus-components.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tailwindcss-stimulus-components.umd.js.map

Large diffs are not rendered by default.

27 changes: 18 additions & 9 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
<head>
<meta charset="UTF-8">
<title>Tailwind Stimulus Components</title>
<link href="https://unpkg.com/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<link href="https://unpkg.com/@tailwindcss/[email protected]/dist/forms.min.css" rel="stylesheet">
<script src="https://unpkg.com/stimulus/dist/stimulus.umd.js"></script>
<script src="https://unpkg.com/tailwindcss-stimulus-components/dist/tailwindcss-stimulus-components.umd.js"></script>
<!-- To use a local copy for testing, uncomment this
<script src="../dist/tailwindcss-stimulus-components.umd.js"></script>
-->
<link href="https://unpkg.com/tailwindcss/dist/tailwind.min.css" rel="stylesheet">
<link href="https://unpkg.com/@tailwindcss/forms/dist/forms.min.css" rel="stylesheet">
<body>
<div class="container mx-auto p-8"
data-controller="slideover"
Expand Down Expand Up @@ -289,9 +284,23 @@ <h2 class="text-2xl text-gray-800 font-semibold mb-4">Color Picker and Preview</
</div>
</div>

<script>
<script type="importmap">
{
"imports": {
"@hotwired/stimulus": "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js",
"tailwindcss-stimulus-components": "https://unpkg.com/tailwindcss-stimulus-components/dist/tailwindcss-stimulus-components.modern.js"
// Uncomment to use local package with "npx serve"
//"tailwindcss-stimulus-components": "../dist/tailwindcss-stimulus-components.modern.js"
}
}
</script>

<script type="module">
import { Application } from "@hotwired/stimulus"
import TailwindcssStimulusComponents from "tailwindcss-stimulus-components"

(() => {
const application = Stimulus.Application.start();
const application = Application.start();
application.register('dropdown', TailwindcssStimulusComponents.Dropdown);
application.register('modal', TailwindcssStimulusComponents.Modal);
application.register('tabs', TailwindcssStimulusComponents.Tabs);
Expand Down
Loading

0 comments on commit 537cd5d

Please sign in to comment.