This repository was archived by the owner on Oct 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f1e8a18
Showing
33 changed files
with
9,214 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Filament Group | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# fg-carousel | ||
|
||
An accessible carousel web component | ||
- @scottjehl @filamentgroup | ||
- MIT License | ||
|
||
- [demo & docs](https://filamentgroup.github.io/fg-carousel/demo/) | ||
- [tests](https://filamentgroup.github.io/fg-carousel/tests/) | ||
|
||
|
||
- NPM https://www.npmjs.com/package/fg-carousel |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
title: '<a href="https://www.filamentgroup.com" class="project-logo">Filament Group</a> <span>carousel</span>' | ||
description: An accessible carousel web component | ||
theme: jekyll-theme-cayman | ||
show_downloads: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
--- | ||
|
||
@import "{{ site.theme }}"; | ||
|
||
.page-header { | ||
background: linear-gradient(#1f7300,#4f9307); | ||
padding: 2rem 4rem; | ||
} | ||
.project-logo { | ||
background: url(https://www.filamentgroup.com/images/svg/fg-logo.svg) 50% 50% no-repeat; | ||
background-size: 90% auto; | ||
display: block; | ||
margin: .2em auto 0; | ||
text-indent: -9999px; | ||
overflow: hidden; | ||
max-width: 170px; | ||
height: 30px | ||
|
||
} | ||
.main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5, .main-content h6 { | ||
color: #2c9915; | ||
} | ||
.project-tagline { | ||
margin-top: .2rem; | ||
opacity: .9; | ||
} | ||
|
||
|
||
.btn { | ||
color: rgba(255,255,255,0.9); | ||
} | ||
|
||
|
||
.btn:hover { | ||
color: rgba(255,255,255,1); | ||
text-decoration: none; | ||
background-color: rgba(255,255,255,0.1); | ||
border-color: rgba(255,255,255,0.6); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
"use strict"; | ||
|
||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
|
||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
|
||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
|
||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
|
||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
|
||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
|
||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
|
||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
|
||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
|
||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
|
||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
|
||
var carousel = /*#__PURE__*/function (_HTMLElement) { | ||
_inherits(carousel, _HTMLElement); | ||
|
||
var _super = _createSuper(carousel); | ||
|
||
function carousel() { | ||
_classCallCheck(this, carousel); | ||
|
||
return _super.call(this); | ||
} | ||
|
||
_createClass(carousel, [{ | ||
key: "connectedCallback", | ||
value: function connectedCallback() { | ||
this.toggletext = "Toggle"; | ||
var toggleAttr = this.getAttribute("toggletext"); | ||
this.toggletext = toggleAttr !== null ? toggleAttr : this.toggletext; | ||
this.carouseld = this.getAttribute("carouseld") !== false; | ||
this.classList.add("carousel"); | ||
this.initEvent = this.makeEvent("init"); | ||
this.expandEvent = this.makeEvent("expand"); | ||
this.carouselEvent = this.makeEvent("carouselEvent"); | ||
this.headerBtn = this.firstElementChild; | ||
this.content = this.headerBtn.nextElementSibling; | ||
this.appendBtn(); | ||
this.setRelationship(); | ||
this.bindEvents(); | ||
this.setState(); | ||
this.dispatchEvent(this.initEvent); | ||
} | ||
}, { | ||
key: "makeEvent", | ||
value: function makeEvent(evtName) { | ||
if (typeof window.CustomEvent === "function") { | ||
return new CustomEvent(evtName, { | ||
bubbles: true, | ||
cancelable: false | ||
}); | ||
} else { | ||
var evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(evtName, true, true, {}); | ||
return evt; | ||
} | ||
} | ||
}, { | ||
key: "appendBtn", | ||
value: function appendBtn() { | ||
var whichMatches = Element.prototype.matches || Element.prototype.msMatchesSelector; | ||
|
||
if (!whichMatches.call(this.headerBtn, "button")) { | ||
var btn = document.createElement("button"); | ||
btn.innerHTML = this.toggletext; | ||
this.headerBtn.appendChild(btn); | ||
this.headerBtn = btn; | ||
} | ||
} | ||
}, { | ||
key: "setRelationship", | ||
value: function setRelationship() { | ||
this.contentId = this.content.id || "carousel_" + new Date().getTime(); | ||
this.content.id = this.contentId; | ||
this.headerBtn.setAttribute("aria-controls", this.content.id); | ||
} | ||
}, { | ||
key: "expand", | ||
value: function expand() { | ||
this.headerBtn.setAttribute("aria-expanded", "true"); | ||
this.removeAttribute("carouseld"); | ||
this.carouseld = false; | ||
this.dispatchEvent(this.expandEvent); | ||
} | ||
}, { | ||
key: "carousel", | ||
value: function carousel() { | ||
this.headerBtn.setAttribute("aria-expanded", "false"); | ||
this.setAttribute("carouseld", ""); | ||
this.carouseld = true; | ||
this.dispatchEvent(this.carouselEvent); | ||
} | ||
}, { | ||
key: "setState", | ||
value: function setState() { | ||
if (this.carouseld) { | ||
this.carousel(); | ||
} else { | ||
this.expand(); | ||
} | ||
} | ||
}, { | ||
key: "toggle", | ||
value: function toggle() { | ||
if (this.carouseld) { | ||
this.expand(); | ||
} else { | ||
this.carousel(); | ||
} | ||
} | ||
}, { | ||
key: "disconnectedCallback", | ||
value: function disconnectedCallback() {// if needed.. | ||
} | ||
}, { | ||
key: "bindEvents", | ||
value: function bindEvents() { | ||
var self = this; | ||
this.firstElementChild.addEventListener('click', function (event) { | ||
return self.toggle(); | ||
}); | ||
} | ||
}]); | ||
|
||
return carousel; | ||
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement)); | ||
|
||
if ('customElements' in window) { | ||
customElements.define('fg-carousel', carousel); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.