Last active
September 10, 2020 02:17
-
-
Save eminkel/5a9194518e2959b24ea21af38309beeb to your computer and use it in GitHub Desktop.
StimulusJS Tag Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="mt-6"> | |
<%= f.label :tags, class: 'form-label' %> | |
<div class="border border-gray-300 rounded-md flex-1 block w-full transition duration-150 ease-in-out pt-1.5 px-2 mt-1" data-controller="tags" data-tags-tag-collection data-tags-autocomplete="true" data-tags-show-dropdown="" data-target="tags.container"> | |
<div class="flex flex-wrap cursor-text" data-action="click->tags#active"> | |
<div class="flex flex-wrap" data-target="tags.tags"> | |
<div class="text-sm p-2 bg-gray-100 rounded-md flex items-center space-x-1.5 mb-1.5 mr-2"> | |
<p>tag</p> | |
<div class="inline-flex bg-gray-500 text-gray-100 rounded-full p-1 hover:bg-gray-700 cursor-pointer"> | |
<svg class="h-3 w-3" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor"><path d="M6 18L18 6M6 6l12 12"></path></svg> | |
</div> | |
</div> | |
<div class="text-sm p-2 bg-gray-100 rounded-md flex items-center space-x-1.5 mb-1.5 mr-2"> | |
<p>stimulusjs</p> | |
<div class="inline-flex bg-gray-500 text-gray-100 rounded-full p-1 hover:bg-gray-700 cursor-pointer"> | |
<svg class="h-3 w-3" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor"><path d="M6 18L18 6M6 6l12 12"></path></svg> | |
</div> | |
</div> | |
</div> | |
<div class="mb-1.5 mr-2"> | |
<%= text_field_tag :tags, nil, class: "text-sm appearance-none outline-none p-2", data: { target: "tags.input", action: "keyup->tags#inputTag keydown->tags#backspaceTag" } %> | |
</div> | |
<div class="hidden absolute text-gray-900 right-0 inset-y-0 flex items-center"> | |
<svg class="h-4 w-4" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor"><path d="M19 9l-7 7-7-7"></path></svg> | |
</div> | |
</div> | |
<%= f.hidden_field :tag_list, data: { target: "tags.data" } %> | |
</div> | |
<p class="input-hint"> | |
Make your submission more discoverable with some tags. | |
</p> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div | |
class="text-sm p-2 bg-gray-100 rounded-md flex items-center space-x-1.5 mb-1.5 mr-2" | |
> | |
<p></p> | |
<div | |
class="inline-flex bg-gray-500 text-gray-100 rounded-full p-1 hover:bg-gray-700 cursor-pointer" | |
data-action="click->tags#removeTag" | |
> | |
<svg | |
class="h-3 w-3" | |
fill="none" | |
stroke-linecap="round" | |
stroke-linejoin="round" | |
stroke-width="2" | |
viewBox="0 0 24 24" | |
stroke="currentColor" | |
> | |
<path d="M6 18L18 6M6 6l12 12"></path> | |
</svg> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://twitter.com/i/status/1284766061586337792