Skip to content

Commit

Permalink
carousel component
Browse files Browse the repository at this point in the history
  • Loading branch information
marcodpt committed Aug 2, 2024
1 parent 564ab1b commit 26adba6
Show file tree
Hide file tree
Showing 17 changed files with 2,020 additions and 19 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inputs and outputs
### Bugs 🐞
- datalist do not work on firefox mobile

### Next release
### Next release 📋
- merge tag and alert inside ctrl

### Improvements 💡
Expand Down Expand Up @@ -47,7 +47,6 @@ inputs and outputs
- core router

### New components 📋
- carousel
- maps
- code component (html/js) and remove highlight.js from page source

Expand Down
23 changes: 20 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<ul class="dropdown-menu">
<li data-app-path="Icons">
<a
href="https://fontawesome.com/search?o=r&m=free&s=solid"
href="https://fontawesome.com/search?o=r&amp;m=free&amp;s=solid"
target="_blank"
class="dropdown-item"
data-app-active="active"
Expand All @@ -163,7 +163,7 @@
</li>
<li data-app-path="Brands">
<a
href="https://fontawesome.com/search?o=r&m=free&f=brands"
href="https://fontawesome.com/search?o=r&amp;m=free&amp;f=brands"
target="_blank"
class="dropdown-item"
data-app-active="active"
Expand Down Expand Up @@ -297,6 +297,23 @@
</span>
</a>
</li>
<li data-app-path="JsBarcode">
<a
href="https://lindell.me/JsBarcode/"
target="_blank"
class="dropdown-item"
data-app-active="active"
title="Barcode component dependency."
>
<span
data-bs-toggle="collapse"
data-bs-target=".navbar-collapse.show"
>
<i class="fa-solid fa-barcode"></i>
JsBarcode
</span>
</a>
</li>
<li data-app-path="QUnit">
<a
href="https://qunitjs.com/api/"
Expand Down Expand Up @@ -413,4 +430,4 @@ <h1 data-app-text="title">App</h1>
</footer>
<script type="module" src="app.js"></script>
</body>
</html>
</html>
3 changes: 2 additions & 1 deletion src/barcode/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export default ({
},
height: {
type: 'integer',
description: 'The height of the img tag in pixels.'
description: 'The height of the img tag in pixels.',
default: 100
}
},
examples: [
Expand Down
Binary file added src/carousel/first.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/carousel/fourth.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 115 additions & 0 deletions src/carousel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import node from '../hyperscript/node.js'
import spinner from '../spinner/index.js'
import {uid} from '../lib.js'

export default ({
images,
index,
interval,
inverted,
noIndicators,
noControls,
noCaption,
noTouch,
fade
}) => {
images = (images || []).map(image => ({
interval,
...image
}))
index = images[index] == null ? 0 : index
const id = uid('carousel')

return node(({
div,
button,
img,
h5,
text,
p,
span
}) =>
div({
id,
class: [
'carousel',
'slide',
fade ? 'carousel-fade' : ''
],
dataBsRide: interval ? 'carousel' : null,
dataBsPause: interval ? 'false' : null,
dataBsTouch: noTouch ? 'false' : null,
dataBsTheme: inverted ? 'dark' : null
}, [
noIndicators ? null : div({
class: 'carousel-indicators'
}, images.map(({title}, i) =>
button({
type: 'button',
dataBsTarget: '#'+id,
dataBsSlideTo: i,
class: i == index ? 'active' : null,
ariaCurrent: i == index ? 'true' : null,
ariaLabel: title
}),
)),
div({
class: 'carousel-inner'
}, images.map(({src, title, description, interval}, i) =>
div({
class: [
'carousel-item',
i == index ? 'active' : ''
],
dataBsInterval: interval
}, [
img({
src,
class: [
'd-block',
'w-100'
],
alt: title,
title: noCaption ? description : null
}),
noCaption || (!title && !description) ? null : div({
class: [
'carousel-caption',
'd-none',
'd-md-block'
]
}, [
!title ? null : h5({}, [
text(title)
]),
!description ? null : p({}, [
text(description)
])
])
])
)),
noControls ? null : button({
class: 'carousel-control-prev',
type: 'button',
dataBsTarget: '#'+id,
dataBsSlide: 'prev'
}, [
span({
class: 'carousel-control-prev-icon',
ariaHidden: 'true'
})
]),
noControls ? null : button({
class: 'carousel-control-next',
type: 'button',
dataBsTarget: '#'+id,
dataBsSlide: 'next'
}, [
span({
class: 'carousel-control-next-icon',
ariaHidden: 'true'
})
])
])
)
}
Binary file added src/carousel/second.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 26adba6

Please sign in to comment.