diff --git a/example/index.html b/example/index.html index de04c2f..601cab9 100644 --- a/example/index.html +++ b/example/index.html @@ -6,6 +6,12 @@ name="viewport" content="width=device-width, initial-scale=1.0" /> SortableTS Examples + + @@ -18,14 +24,14 @@ class="w-32" /> -
+

SortableTS

TypeScript library for reorderable drag-and-drop lists

-
- - -
-
-

Simple List

-
-
Item 1
-
Item 2
-
Item 3
-
Item 4
-
Item 5
-
-
-
-              
-                new Sortable(example1, {
-                  animation: 150,
-                  ghostClass: 'opacity-50'
-                });
+      
+      
+ +
+
+

Simple List

+
+
Item 1
+
Item 2
+
Item 3
+
Item 4
+
Item 5
+
+
+ +

new Sortable(example1, {

+

animation: 150,

+

ghostClass: 'opacity-50'

+

});

-
+
-
- + - -
-
-

Shared Lists

-
-
-
Item 1
-
Item 2
-
Item 3
+ +
+
+

Shared Lists

+
+
+
Item 1
+
Item 2
+
Item 3
+
Item 4
+
Item 5
+
+
+
Item 6
+
Item 7
+
Item 8
+
Item 9
+
Item 10
+
-
-
Item 4
-
Item 5
-
Item 6
+
+
+ +

new Sortable(example2Left, {

+

group: 'shared', // set both lists to same group

+

animation: 150

+

});

+
+
+
+ +

new Sortable(example2Right, {

+

group: 'shared',

+

animation: 150

+

});

+
+
-
-
-              new Sortable(example2Left, {
-                group: 'shared',
-                animation: 150
-              });
+        
- new Sortable(example2Right, { - group: 'shared', - animation: 150 - }); - + +
+
+

Cloning

+

Try dragging from one list to another. The item you drag will be cloned and the clone will stay in the original list.

+
+
+
Item 1
+
Item 2
+
Item 3
+
Item 4
+
Item 5
+
+
+
Item 6
+
Item 7
+
Item 8
+
Item 9
+
Item 10
+
+
+
+
+ +

new Sortable(example3Left, {

+
+ group: { +

name: 'shared',

+

pull: 'clone' // To clone: set pull to 'clone'

+

},

+
+

animation: 150

+

});

+
+
+
+ +

new Sortable(example3Right, {

+
+ group: { +

name: 'shared',

+

pull: 'clone'

+

},

+
+

animation: 150

+

});

+
+
+
-
-
+ - -
-
-

Handle

-
-
- - Item 1 -
-
- - Item 2 + +
+
+

Disabling Sorting

+

Try sorting the list on the left. It is not possible because it has it's sort option set to false. However, you can still drag from the list on the left to the list on the right.

+
+
+
Item 1
+
Item 2
+
Item 3
+
Item 4
+
Item 5
+
+
+
Item 6
+
Item 7
+
Item 8
+
Item 9
+
Item 10
+
-
- - Item 3 +
+
+ +

new Sortable(example4Left, {

+
+ group: { +

name: 'shared',

+

pull: 'clone'

+

put: false // Do not allow items to be put into this list

+

},

+
+

animation: 150,

+

sort: false // To disable sorting: set sort to false

+

});

+
+
+
+ +

new Sortable(example4Right, {

+

group: 'shared',

+

animation: 150

+

});

+
+
-
-
-              new Sortable(example5, {
-                  handle: '.handle',
-                  animation: 150
-               });
-            
-          
-
-
-
+
- -
-
-

Grid

-
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
+ +
+
+

Handle

+
+
+ + Item 1 +
+
+ + Item 2 +
+
+ + Item 3 +
+
+ + Item 4 +
+
+ + Item 5 +
+
+
+ +

new Sortable(example5, {

+

handle: '.handle', // handle's class

+

animation: 150

+

});

+
+
-
-
-
+ - -
-
-

Cloning

-

Try dragging from one list to another. The item you drag will be cloned and the clone will stay in the original list.

-
-
-
Item 1
-
Item 2
-
Item 3
-
-
-
Item 4
-
Item 5
-
Item 6
+ +
+
+

Filter

+

Try dragging the item with a red background. It cannot be done, because that item is filtered out using the filter option.

+
+
Item 1
+
Item 2
+
Item 3
+
Filtered
+
Item 4
+
Item 5
+
+
+ +

new Sortable(example5, {

+

handle: '.handle', // handle's class

+

animation: 150

+

});

+
+
-
-
-
new Sortable(example3Left, {
-            group: {
-              name: 'shared',
-              pull: 'clone'
-            },
-            animation: 150
-          });
-
-          new Sortable(example3Right, {
-            group: {
-              name: 'shared',
-              pull: 'clone'
-            },
-            animation: 150
-          });
-
+
- - -
-
-

Disable Sorting

-

Try sorting the list on the left. It is not possible because it has its sort option set to false. However, you can still drag from the left list to the right list.

-
-
-
Item 1
-
Item 2
-
Item 3
-
-
-
Item 4
-
Item 5
-
Item 6
+ +
+

Examples

+ +
+
+

Grid Example

+
+
Item 1
+
Item 2
+
Item 3
+
Item 4
+
Item 5
+
Item 6
+
Item 7
+
Item 8
+
Item 9
+
Item 10
+
Item 11
+
Item 12
+
Item 13
+
Item 14
+
Item 15
+
Item 16
+
Item 17
+
Item 18
+
Item 19
+
Item 20
+
Item 21
+
Item 22
+
Item 23
+
Item 24
+
-
-
-
new Sortable(example4Left, {
-            group: {
-              name: 'shared',
-              pull: 'clone',
-              put: false
-            },
-            animation: 150,
-            sort: false
-          });
-
-          new Sortable(example4Right, {
-            group: 'shared',
-            animation: 150
-          });
-
-
-
- - -
-
-

Filter

-

Try dragging the item with a red background. It cannot be done because that item is filtered out using the filter option.

-
-
Item 1
-
Item 2
-
Filtered Item (Can't move)
-
Item 3
-
Item 4
-
-
-
new Sortable(example6, {
-            filter: '.filtered',
-            animation: 150
-          });
-
-
-
- - -
-
-

Nested Sortables

-

Items can be nested indefinitely and you can drag and drop between nested lists.

-
-
-
Item 1
-
-
Nested Item 1.1
-
Nested Item 1.2
-
-
Nested Item 1.3
-
-
Sub-nested Item 1.3.1
-
Sub-nested Item 1.3.2
+
+ +
+
+

Nested Sortables

+

+ NOTE: When using nested Sortables with animation, it is recommended that the fallbackOnBody option is set to true. It is also always recommended that either the invertSwap option is set to true, or the swapThreshold option is lower than the default value of 1 (eg 0.65). +

+
+
+
Item 1.1
+
+
Item 2.1
+
+
Item 2.2
+
+
Item 3.1
+
Item 3.2
+
Item 3.3
+
Item 3.4
+
+
+
+
+
+
Item 1.2
+
+
+
Item 1.3
+
+
+
Item 1.4
+
+
Nested Item 2.1
+
Nested Item 2.2
+
Nested Item 2.3
+
Nested Item 2.4
-
-
-
Item 2
-
-
Nested Item 2.1
-
Nested Item 2.2
+
+
+ +

// Loop through each nested sortable element

+

+ for (var i = 0; i < nestedSortables.length; i++ ) { +

+
+

new Sortable (nestedSortables[i], {

+

group: 'nested',

+

animation: 150,

+ +

fallbackOnBody: true,

+

swapThreshold: 0.89

+

});

+
+

}

+
+
-
-
-
// Loop through each nested sortable element
-            document.querySelectorAll('.nested-sortable').forEach(el => {
-              new Sortable(el, {
-                group: 'nested',
-                animation: 150,
-                fallbackOnBody: true,
-                swapThreshold: 0.65
-              });
-            });
-
+
- + + diff --git a/example/src/output.css b/example/src/output.css new file mode 100644 index 0000000..4e80d17 --- /dev/null +++ b/example/src/output.css @@ -0,0 +1,1122 @@ +*, ::before, ::after { + --tw-border-spacing-x: 0; + --tw-border-spacing-y: 0; + --tw-translate-x: 0; + --tw-translate-y: 0; + --tw-rotate: 0; + --tw-skew-x: 0; + --tw-skew-y: 0; + --tw-scale-x: 1; + --tw-scale-y: 1; + --tw-pan-x: ; + --tw-pan-y: ; + --tw-pinch-zoom: ; + --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; + --tw-ordinal: ; + --tw-slashed-zero: ; + --tw-numeric-figure: ; + --tw-numeric-spacing: ; + --tw-numeric-fraction: ; + --tw-ring-inset: ; + --tw-ring-offset-width: 0px; + --tw-ring-offset-color: #fff; + --tw-ring-color: rgb(59 130 246 / 0.5); + --tw-ring-offset-shadow: 0 0 #0000; + --tw-ring-shadow: 0 0 #0000; + --tw-shadow: 0 0 #0000; + --tw-shadow-colored: 0 0 #0000; + --tw-blur: ; + --tw-brightness: ; + --tw-contrast: ; + --tw-grayscale: ; + --tw-hue-rotate: ; + --tw-invert: ; + --tw-saturate: ; + --tw-sepia: ; + --tw-drop-shadow: ; + --tw-backdrop-blur: ; + --tw-backdrop-brightness: ; + --tw-backdrop-contrast: ; + --tw-backdrop-grayscale: ; + --tw-backdrop-hue-rotate: ; + --tw-backdrop-invert: ; + --tw-backdrop-opacity: ; + --tw-backdrop-saturate: ; + --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; +} + +::backdrop { + --tw-border-spacing-x: 0; + --tw-border-spacing-y: 0; + --tw-translate-x: 0; + --tw-translate-y: 0; + --tw-rotate: 0; + --tw-skew-x: 0; + --tw-skew-y: 0; + --tw-scale-x: 1; + --tw-scale-y: 1; + --tw-pan-x: ; + --tw-pan-y: ; + --tw-pinch-zoom: ; + --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; + --tw-ordinal: ; + --tw-slashed-zero: ; + --tw-numeric-figure: ; + --tw-numeric-spacing: ; + --tw-numeric-fraction: ; + --tw-ring-inset: ; + --tw-ring-offset-width: 0px; + --tw-ring-offset-color: #fff; + --tw-ring-color: rgb(59 130 246 / 0.5); + --tw-ring-offset-shadow: 0 0 #0000; + --tw-ring-shadow: 0 0 #0000; + --tw-shadow: 0 0 #0000; + --tw-shadow-colored: 0 0 #0000; + --tw-blur: ; + --tw-brightness: ; + --tw-contrast: ; + --tw-grayscale: ; + --tw-hue-rotate: ; + --tw-invert: ; + --tw-saturate: ; + --tw-sepia: ; + --tw-drop-shadow: ; + --tw-backdrop-blur: ; + --tw-backdrop-brightness: ; + --tw-backdrop-contrast: ; + --tw-backdrop-grayscale: ; + --tw-backdrop-hue-rotate: ; + --tw-backdrop-invert: ; + --tw-backdrop-opacity: ; + --tw-backdrop-saturate: ; + --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; +} + +/* +! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com +*/ + +/* +1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4) +2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116) +*/ + +*, +::before, +::after { + box-sizing: border-box; + /* 1 */ + border-width: 0; + /* 2 */ + border-style: solid; + /* 2 */ + border-color: #e5e7eb; + /* 2 */ +} + +::before, +::after { + --tw-content: ''; +} + +/* +1. Use a consistent sensible line-height in all browsers. +2. Prevent adjustments of font size after orientation changes in iOS. +3. Use a more readable tab size. +4. Use the user's configured `sans` font-family by default. +5. Use the user's configured `sans` font-feature-settings by default. +6. Use the user's configured `sans` font-variation-settings by default. +7. Disable tap highlights on iOS +*/ + +html, +:host { + line-height: 1.5; + /* 1 */ + -webkit-text-size-adjust: 100%; + /* 2 */ + -moz-tab-size: 4; + /* 3 */ + -o-tab-size: 4; + tab-size: 4; + /* 3 */ + font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + /* 4 */ + font-feature-settings: normal; + /* 5 */ + font-variation-settings: normal; + /* 6 */ + -webkit-tap-highlight-color: transparent; + /* 7 */ +} + +/* +1. Remove the margin in all browsers. +2. Inherit line-height from `html` so users can set them as a class directly on the `html` element. +*/ + +body { + margin: 0; + /* 1 */ + line-height: inherit; + /* 2 */ +} + +/* +1. Add the correct height in Firefox. +2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655) +3. Ensure horizontal rules are visible by default. +*/ + +hr { + height: 0; + /* 1 */ + color: inherit; + /* 2 */ + border-top-width: 1px; + /* 3 */ +} + +/* +Add the correct text decoration in Chrome, Edge, and Safari. +*/ + +abbr:where([title]) { + -webkit-text-decoration: underline dotted; + text-decoration: underline dotted; +} + +/* +Remove the default font size and weight for headings. +*/ + +h1, +h2, +h3, +h4, +h5, +h6 { + font-size: inherit; + font-weight: inherit; +} + +/* +Reset links to optimize for opt-in styling instead of opt-out. +*/ + +a { + color: inherit; + text-decoration: inherit; +} + +/* +Add the correct font weight in Edge and Safari. +*/ + +b, +strong { + font-weight: bolder; +} + +/* +1. Use the user's configured `mono` font-family by default. +2. Use the user's configured `mono` font-feature-settings by default. +3. Use the user's configured `mono` font-variation-settings by default. +4. Correct the odd `em` font sizing in all browsers. +*/ + +code, +kbd, +samp, +pre { + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + /* 1 */ + font-feature-settings: normal; + /* 2 */ + font-variation-settings: normal; + /* 3 */ + font-size: 1em; + /* 4 */ +} + +/* +Add the correct font size in all browsers. +*/ + +small { + font-size: 80%; +} + +/* +Prevent `sub` and `sup` elements from affecting the line height in all browsers. +*/ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +/* +1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297) +2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016) +3. Remove gaps between table borders by default. +*/ + +table { + text-indent: 0; + /* 1 */ + border-color: inherit; + /* 2 */ + border-collapse: collapse; + /* 3 */ +} + +/* +1. Change the font styles in all browsers. +2. Remove the margin in Firefox and Safari. +3. Remove default padding in all browsers. +*/ + +button, +input, +optgroup, +select, +textarea { + font-family: inherit; + /* 1 */ + font-feature-settings: inherit; + /* 1 */ + font-variation-settings: inherit; + /* 1 */ + font-size: 100%; + /* 1 */ + font-weight: inherit; + /* 1 */ + line-height: inherit; + /* 1 */ + letter-spacing: inherit; + /* 1 */ + color: inherit; + /* 1 */ + margin: 0; + /* 2 */ + padding: 0; + /* 3 */ +} + +/* +Remove the inheritance of text transform in Edge and Firefox. +*/ + +button, +select { + text-transform: none; +} + +/* +1. Correct the inability to style clickable types in iOS and Safari. +2. Remove default button styles. +*/ + +button, +input:where([type='button']), +input:where([type='reset']), +input:where([type='submit']) { + -webkit-appearance: button; + /* 1 */ + background-color: transparent; + /* 2 */ + background-image: none; + /* 2 */ +} + +/* +Use the modern Firefox focus style for all focusable elements. +*/ + +:-moz-focusring { + outline: auto; +} + +/* +Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737) +*/ + +:-moz-ui-invalid { + box-shadow: none; +} + +/* +Add the correct vertical alignment in Chrome and Firefox. +*/ + +progress { + vertical-align: baseline; +} + +/* +Correct the cursor style of increment and decrement buttons in Safari. +*/ + +::-webkit-inner-spin-button, +::-webkit-outer-spin-button { + height: auto; +} + +/* +1. Correct the odd appearance in Chrome and Safari. +2. Correct the outline style in Safari. +*/ + +[type='search'] { + -webkit-appearance: textfield; + /* 1 */ + outline-offset: -2px; + /* 2 */ +} + +/* +Remove the inner padding in Chrome and Safari on macOS. +*/ + +::-webkit-search-decoration { + -webkit-appearance: none; +} + +/* +1. Correct the inability to style clickable types in iOS and Safari. +2. Change font properties to `inherit` in Safari. +*/ + +::-webkit-file-upload-button { + -webkit-appearance: button; + /* 1 */ + font: inherit; + /* 2 */ +} + +/* +Add the correct display in Chrome and Safari. +*/ + +summary { + display: list-item; +} + +/* +Removes the default spacing and border for appropriate elements. +*/ + +blockquote, +dl, +dd, +h1, +h2, +h3, +h4, +h5, +h6, +hr, +figure, +p, +pre { + margin: 0; +} + +fieldset { + margin: 0; + padding: 0; +} + +legend { + padding: 0; +} + +ol, +ul, +menu { + list-style: none; + margin: 0; + padding: 0; +} + +/* +Reset default styling for dialogs. +*/ + +dialog { + padding: 0; +} + +/* +Prevent resizing textareas horizontally by default. +*/ + +textarea { + resize: vertical; +} + +/* +1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300) +2. Set the default placeholder color to the user's configured gray 400 color. +*/ + +input::-moz-placeholder, textarea::-moz-placeholder { + opacity: 1; + /* 1 */ + color: #9ca3af; + /* 2 */ +} + +input::placeholder, +textarea::placeholder { + opacity: 1; + /* 1 */ + color: #9ca3af; + /* 2 */ +} + +/* +Set the default cursor for buttons. +*/ + +button, +[role="button"] { + cursor: pointer; +} + +/* +Make sure disabled buttons don't get the pointer cursor. +*/ + +:disabled { + cursor: default; +} + +/* +1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14) +2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210) + This can trigger a poorly considered lint error in some tools but is included by design. +*/ + +img, +svg, +video, +canvas, +audio, +iframe, +embed, +object { + display: block; + /* 1 */ + vertical-align: middle; + /* 2 */ +} + +/* +Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14) +*/ + +img, +video { + max-width: 100%; + height: auto; +} + +/* Make elements with the HTML hidden attribute stay hidden by default */ + +[hidden]:where(:not([hidden="until-found"])) { + display: none; +} + +.container { + width: 100%; +} + +@media (min-width: 640px) { + .container { + max-width: 640px; + } +} + +@media (min-width: 768px) { + .container { + max-width: 768px; + } +} + +@media (min-width: 1024px) { + .container { + max-width: 1024px; + } +} + +@media (min-width: 1280px) { + .container { + max-width: 1280px; + } +} + +@media (min-width: 1536px) { + .container { + max-width: 1536px; + } +} + +.fixed { + position: fixed; +} + +.right-0 { + right: 0px; +} + +.top-0 { + top: 0px; +} + +.z-50 { + z-index: 50; +} + +.mx-auto { + margin-left: auto; + margin-right: auto; +} + +.mb-12 { + margin-bottom: 3rem; +} + +.mb-2 { + margin-bottom: 0.5rem; +} + +.mb-3 { + margin-bottom: 0.75rem; +} + +.mb-4 { + margin-bottom: 1rem; +} + +.mb-8 { + margin-bottom: 2rem; +} + +.ml-6 { + margin-left: 1.5rem; +} + +.mr-3 { + margin-right: 0.75rem; +} + +.mt-3 { + margin-top: 0.75rem; +} + +.mt-4 { + margin-top: 1rem; +} + +.mt-6 { + margin-top: 1.5rem; +} + +.mb-6 { + margin-bottom: 1.5rem; +} + +.flex { + display: flex; +} + +.grid { + display: grid; +} + +.h-12 { + height: 3rem; +} + +.h-24 { + height: 6rem; +} + +.h-20 { + height: 5rem; +} + +.min-h-screen { + min-height: 100vh; +} + +.w-32 { + width: 8rem; +} + +.w-full { + width: 100%; +} + +.max-w-2xl { + max-width: 42rem; +} + +.max-w-\[960px\] { + max-width: 960px; +} + +.cursor-move { + cursor: move; +} + +.grid-cols-2 { + grid-template-columns: repeat(2, minmax(0, 1fr)); +} + +.items-start { + align-items: flex-start; +} + +.items-center { + align-items: center; +} + +.justify-between { + justify-content: space-between; +} + +.gap-3 { + gap: 0.75rem; +} + +.gap-4 { + gap: 1rem; +} + +.gap-6 { + gap: 1.5rem; +} + +.gap-8 { + gap: 2rem; +} + +.space-y-2 > :not([hidden]) ~ :not([hidden]) { + --tw-space-y-reverse: 0; + margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse))); + margin-bottom: calc(0.5rem * var(--tw-space-y-reverse)); +} + +.space-y-4 > :not([hidden]) ~ :not([hidden]) { + --tw-space-y-reverse: 0; + margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse))); + margin-bottom: calc(1rem * var(--tw-space-y-reverse)); +} + +.space-y-1 > :not([hidden]) ~ :not([hidden]) { + --tw-space-y-reverse: 0; + margin-top: calc(0.25rem * calc(1 - var(--tw-space-y-reverse))); + margin-bottom: calc(0.25rem * var(--tw-space-y-reverse)); +} + +.overflow-hidden { + overflow: hidden; +} + +.rounded { + border-radius: 0.25rem; +} + +.rounded-\[5px\] { + border-radius: 5px; +} + +.rounded-\[8px\] { + border-radius: 8px; +} + +.rounded-lg { + border-radius: 0.5rem; +} + +.border { + border-width: 1px; +} + +.border-b-\[1px\] { + border-bottom-width: 1px; +} + +.border-l-\[1px\] { + border-left-width: 1px; +} + +.border-blue-200 { + --tw-border-opacity: 1; + border-color: rgb(191 219 254 / var(--tw-border-opacity, 1)); +} + +.border-gray-200 { + --tw-border-opacity: 1; + border-color: rgb(229 231 235 / var(--tw-border-opacity, 1)); +} + +.border-green-200 { + --tw-border-opacity: 1; + border-color: rgb(187 247 208 / var(--tw-border-opacity, 1)); +} + +.border-red-200 { + --tw-border-opacity: 1; + border-color: rgb(254 202 202 / var(--tw-border-opacity, 1)); +} + +.bg-blue-50 { + --tw-bg-opacity: 1; + background-color: rgb(239 246 255 / var(--tw-bg-opacity, 1)); +} + +.bg-gray-50 { + --tw-bg-opacity: 1; + background-color: rgb(249 250 251 / var(--tw-bg-opacity, 1)); +} + +.bg-gray-800 { + --tw-bg-opacity: 1; + background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1)); +} + +.bg-green-50 { + --tw-bg-opacity: 1; + background-color: rgb(240 253 244 / var(--tw-bg-opacity, 1)); +} + +.bg-red-100 { + --tw-bg-opacity: 1; + background-color: rgb(254 226 226 / var(--tw-bg-opacity, 1)); +} + +.bg-red-900 { + --tw-bg-opacity: 1; + background-color: rgb(127 29 29 / var(--tw-bg-opacity, 1)); +} + +.bg-white { + --tw-bg-opacity: 1; + background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1)); +} + +.bg-red-500 { + --tw-bg-opacity: 1; + background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1)); +} + +.bg-red-400 { + --tw-bg-opacity: 1; + background-color: rgb(248 113 113 / var(--tw-bg-opacity, 1)); +} + +.bg-red-600 { + --tw-bg-opacity: 1; + background-color: rgb(220 38 38 / var(--tw-bg-opacity, 1)); +} + +.p-2 { + padding: 0.5rem; +} + +.p-3 { + padding: 0.75rem; +} + +.p-4 { + padding: 1rem; +} + +.p-6 { + padding: 1.5rem; +} + +.px-4 { + padding-left: 1rem; + padding-right: 1rem; +} + +.px-8 { + padding-left: 2rem; + padding-right: 2rem; +} + +.py-3 { + padding-top: 0.75rem; + padding-bottom: 0.75rem; +} + +.py-4 { + padding-top: 1rem; + padding-bottom: 1rem; +} + +.py-8 { + padding-top: 2rem; + padding-bottom: 2rem; +} + +.px-3 { + padding-left: 0.75rem; + padding-right: 0.75rem; +} + +.pl-4 { + padding-left: 1rem; +} + +.pb-4 { + padding-bottom: 1rem; +} + +.text-center { + text-align: center; +} + +.text-2xl { + font-size: 1.5rem; + line-height: 2rem; +} + +.text-4xl { + font-size: 2.25rem; + line-height: 2.5rem; +} + +.text-xl { + font-size: 1.25rem; + line-height: 1.75rem; +} + +.text-3xl { + font-size: 1.875rem; + line-height: 2.25rem; +} + +.text-sm { + font-size: 0.875rem; + line-height: 1.25rem; +} + +.font-bold { + font-weight: 700; +} + +.font-medium { + font-weight: 500; +} + +.font-semibold { + font-weight: 600; +} + +.text-black { + --tw-text-opacity: 1; + color: rgb(0 0 0 / var(--tw-text-opacity, 1)); +} + +.text-blue-600 { + --tw-text-opacity: 1; + color: rgb(37 99 235 / var(--tw-text-opacity, 1)); +} + +.text-gray-100 { + --tw-text-opacity: 1; + color: rgb(243 244 246 / var(--tw-text-opacity, 1)); +} + +.text-gray-600 { + --tw-text-opacity: 1; + color: rgb(75 85 99 / var(--tw-text-opacity, 1)); +} + +.text-gray-900 { + --tw-text-opacity: 1; + color: rgb(17 24 39 / var(--tw-text-opacity, 1)); +} + +.text-slate-300 { + --tw-text-opacity: 1; + color: rgb(203 213 225 / var(--tw-text-opacity, 1)); +} + +.text-style_blue { + --tw-text-opacity: 1; + color: rgb(0 0 136 / var(--tw-text-opacity, 1)); +} + +.text-style_class { + --tw-text-opacity: 1; + color: rgb(102 0 102 / var(--tw-text-opacity, 1)); +} + +.text-style_comment { + --tw-text-opacity: 1; + color: rgb(136 0 0 / var(--tw-text-opacity, 1)); +} + +.text-style_num { + --tw-text-opacity: 1; + color: rgb(0 102 102 / var(--tw-text-opacity, 1)); +} + +.text-style_str { + --tw-text-opacity: 1; + color: rgb(0 136 0 / var(--tw-text-opacity, 1)); +} + +.text-gray-300 { + --tw-text-opacity: 1; + color: rgb(209 213 219 / var(--tw-text-opacity, 1)); +} + +.opacity-50 { + opacity: 0.5; +} + +.opacity-80 { + opacity: 0.8; +} + +.shadow-sm { + --tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); + --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color); + box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); +} + +.filter { + filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow); +} + +.transition-colors { + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + transition-duration: 150ms; +} + +* { + scroll-behavior: smooth; +} + +/* Dragging states */ + +.dragging { + cursor: grabbing; + opacity: 0.5; +} + +.sortable-ghost { + opacity: 0.5; +} + +.sortable-drag { + cursor: grabbing; +} + +/* Code blocks */ + +pre { + overflow-x: auto; +} + +code { + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + font-size: 0.875rem; + line-height: 1.25rem; +} + +/* Handle styles */ + +.handle { + cursor: move; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + transition-duration: 150ms; +} + +.handle:hover { + --tw-text-opacity: 1; + color: rgb(75 85 99 / var(--tw-text-opacity, 1)); +} + +/* Grid item styles */ + +.grid-item { + display: flex; + aspect-ratio: 1 / 1; + align-items: center; + justify-content: center; +} + +.hover\:bg-blue-100:hover { + --tw-bg-opacity: 1; + background-color: rgb(219 234 254 / var(--tw-bg-opacity, 1)); +} + +.hover\:bg-gray-100:hover { + --tw-bg-opacity: 1; + background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1)); +} + +.hover\:text-blue-800:hover { + --tw-text-opacity: 1; + color: rgb(30 64 175 / var(--tw-text-opacity, 1)); +} + +@media (min-width: 640px) { + .sm\:grid-cols-3 { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } +} + +@media (min-width: 768px) { + .md\:grid-cols-2 { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + + .md\:grid-cols-4 { + grid-template-columns: repeat(4, minmax(0, 1fr)); + } + + .md\:grid-cols-6 { + grid-template-columns: repeat(6, minmax(0, 1fr)); + } + + .md\:grid-cols-8 { + grid-template-columns: repeat(8, minmax(0, 1fr)); + } +} diff --git a/example/src/style.css b/example/src/style.css index 7268235..4a7aa3f 100644 --- a/example/src/style.css +++ b/example/src/style.css @@ -2,6 +2,10 @@ @tailwind components; @tailwind utilities; +* { + scroll-behavior: smooth; +} + /* Dragging states */ .dragging { @apply opacity-50 cursor-grabbing; diff --git a/example/styles.css b/example/styles.css new file mode 100644 index 0000000..b05f787 --- /dev/null +++ b/example/styles.css @@ -0,0 +1,164 @@ +* { + padding: 0; + margin: 0; + box-sizing: border-box; + font-family: 'Helvetica Neue', Helvetica, Arial; + font-weight: 300; +} +body { + background-color: rgb(244, 215, 201); + padding: 20px; + color: #212529; +} +body .container { + max-width: 1140px; + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + margin: 0 auto; +} + +.logo { + display: flex; + align-items: center; + flex-direction: column; +} +.logo .image { + width: 200px; + height: 100px; + background-color: green; +} + +.logo h3 { + font-weight: 300; + font-size: 40px; +} + +.desc { + font-weight: normal; +} + +#features_examples_plugins { + width: 45%; + max-width: 720px; + padding: 30px; + height: auto; + border: 1px solid #444; + background-color: rgb(255, 255, 255, 0.5); + margin-top: 20px; +} +#features_examples_plugins > div { + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; +} + +#features_examples_plugins > div > h3 { + margin-bottom: 10px; + font-weight: 300; +} +#features_examples_plugins > div > a { + display: block; + color: #007bff; + text-decoration: none; + font-weight: 300; + margin-bottom: 8px; +} + +#features { + width: 100%; + margin-top: 20px; +} + +#features > h3 { + padding: 0 0 10px 0; + font-size: 32px; +} +#features .feature h3 { + padding: 20px 10px; + font-size: 24px; + border-top: 1px solid rgba(0, 0, 0, 0.125); +} +#features .feature .feature_desc { + padding: 0px 0 20px 10px; +} + +#features .feature .double { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 10px; +} + +#features .feature > div > p { + font-size: 20px; +} + +#features .feature ul { + width: 100%; + list-style-type: none; + border-radius: 5px; + overflow: hidden; +} +#features .feature ul li { + width: full; + background-color: white; + padding: 15px; + border-bottom: 1px solid rgba(0, 0, 0, 0.125); + display: flex; + align-items: center; + gap: 8px; +} +#features .feature ul.exampleRight li { + background-color: #fff6b2; +} +#features .feature .code { + padding: 5px 20px; + margin: 10px 0; + border-left: 1px solid #888; + display: flex; + flex-direction: column; + gap: 12px; +} +#features .feature .code .style, +#features .feature .code { + font-size: 14px; + color: #000000; +} + +#features .feature .code .new, +#features .feature .code .group { + color: #000088; +} +#features .feature .code .class { + color: #660066; +} +#features .feature .code .symbol { + color: #660; +} +#features .feature .code .style_num { + color: #006666; +} +#features .feature .code .comment { + color: #800; +} +#features .feature .code .style_str { + color: #008800; +} +#features .feature .code .style_bool { + color: #000088; +} +#features .feature .code .style { + padding: 5px 0px 0 20px; +} +#features .feature ul li button { + width: 24px; + height: 24px; + background-color: red; + border: 0; + display: flex; + align-items: center; + justify-content: center; +} diff --git a/example/tailwind.config.js b/example/tailwind.config.js deleted file mode 100644 index dca8ba0..0000000 --- a/example/tailwind.config.js +++ /dev/null @@ -1,11 +0,0 @@ -/** @type {import('tailwindcss').Config} */ -export default { - content: [ - "./index.html", - "./src/**/*.{js,ts,jsx,tsx}", - ], - theme: { - extend: {}, - }, - plugins: [], -} diff --git a/example/tsconfig.json b/example/tsconfig.json deleted file mode 100644 index 7c99a69..0000000 --- a/example/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "baseUrl": ".", - "moduleResolution": "bundler", - "allowJs": true, - "types": ["vite/client"] - }, - "include": ["src/**/*"] -} diff --git a/package.json b/package.json index 1feedba..6e45c9f 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "build": "vite build && rollup -c", "preview": "vite preview", "clean": "rimraf dist", - "example": "npm run build && vite example" + "example": "npm run build && vite example", + "styles": "npx tailwindcss -i ./example/src/style.css -o ./example/src/output.css -w" }, "devDependencies": { "@rollup/plugin-typescript": "^12.1.2", diff --git a/example/postcss.config.js b/postcss.config.js similarity index 100% rename from example/postcss.config.js rename to postcss.config.js diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..3998927 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,16 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: ['./example/*.html', './example/**/*.html'], + theme: { + extend: { + colors: { + style_str: '#008800', + style_blue: '#000088', + style_num: '#006666', + style_class: '#660066', + style_comment: '#800', + }, + }, + }, + plugins: [], +};