excid3 / tailwindcss-stimulus-components

A set of StimulusJS components for TailwindCSS apps similar to Bootstrap JS components.

Home Page:https://excid3.github.io/tailwindcss-stimulus-components/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alert example throws error: v3.0.3 & Stimulus v3.01

mrjonesbot opened this issue · comments

Error is thrown on connect and on click action.

Screen Shot 2022-01-31 at 10 55 35 PM

Can you click on that line in Stimulus.js and share what that is? Curious where it's falling over inside Stimulus. Looks to be the classes API.

According to the docs, we're using that properly? https://stimulus.hotwired.dev/reference/css-classes#properties

I think it's because the example doesn't declare a class for the controller to use in the HTML, like:

data-search-loading-class="bg-gray-500 animate-spinner cursor-busy">

At least, that's what it looks like in the docs.

Screen Shot 2022-02-01 at 9 24 49 AM

Declare a css class reference, then declare the class on the data attribute.

Ah, so maybe its undefined or null instead of an empty array?

Removing the classes on the first alert example correctly gave me [] and the other is an array as well.

Screen Shot 2022-02-01 at 12 00 32 PM

Looks like it's working correctly?

Are you using @hotwired/stimulus

Yep

Screen Shot 2022-02-01 at 12 02 52 PM

Does it matter what version of Rails I'm on?

Going to clear my yarn cache and see if that resolves the issue.

I'm still not seeing the data-attribute mapping for these classes in the example though.

Hmm, I guess can you stick a console.log() in the node_modules and see if it's not an array for your example?

I wish I could just start over on Rails 7 lmao

When I dig into my node_modules, propertiesForClassDefinition is not matching the current version somehow.

Screen Shot 2022-02-01 at 1 11 46 PM

I was importing Stimulus from the wrong package, so let me update those refs and get back to you.

Ok so, I updated my references and received a fun new error.

app/javascript/controllers/index.js

// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js.

import { Application } from "@hotwired/stimulus"
import { definitionsFromContext } from "@hotwired/stimulus-webpack-helpers"
import { Autocomplete } from 'stimulus-autocomplete'

const application = Application.start()
const context = require.context("controllers", true, /_controller\.js$/)
application.load(definitionsFromContext(context))

application.register('autocomplete', Autocomplete)

import { Alert, Dropdown, Modal, Tabs, Popover, Toggle, Slideover } from "tailwindcss-stimulus-components"
application.register('alert', Alert)
application.register('dropdown', Dropdown)
application.register('modal', Modal)
application.register('tabs', Tabs)
application.register('popover', Popover)
application.register('toggle', Toggle)
application.register('slideover', Slideover)

import Flatpickr from 'stimulus-flatpickr'
application.register('flatpickr', Flatpickr)

import StimulusReflex from 'stimulus_reflex'
import consumer from '../channels/consumer'
import controller from './application_controller'
StimulusReflex.initialize(application, { consumer, controller, debug: false })

Screen Shot 2022-02-01 at 1 16 42 PM

Screen Shot 2022-02-01 at 1 17 45 PM

Ok it actually looks like my install of StimulusReflex is causing issues with my controllers, since I'm in the process of ripping it out anyways, I'm going to do that and circle back.