├── .editorconfig
├── .eslintrc
├── .gitignore
├── .stylelintrc
├── .travis.yml
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── lerna.json
├── package.json
├── packages
├── accordion-list-element
│ ├── README.md
│ ├── package.json
│ └── src
│ │ ├── browser.js
│ │ ├── example.html
│ │ ├── index.css
│ │ └── index.js
├── accordion-panel-element
│ ├── README.md
│ ├── package.json
│ └── src
│ │ ├── browser.js
│ │ ├── example.html
│ │ ├── index.css
│ │ └── index.js
├── domset-svg
│ ├── README.md
│ ├── package.json
│ └── src
│ │ ├── example.html
│ │ └── index.js
├── domset
│ ├── README.md
│ ├── package.json
│ └── src
│ │ ├── example.html
│ │ └── index.js
├── intersection-image-element
│ ├── README.md
│ ├── package.json
│ └── src
│ │ ├── browser.js
│ │ ├── example.html
│ │ ├── index.css
│ │ └── index.js
├── media-player-element
│ ├── README.md
│ ├── package.json
│ └── src
│ │ ├── browser.js
│ │ ├── example.html
│ │ ├── index.css
│ │ ├── index.js
│ │ └── lib
│ │ ├── define-dom.js
│ │ ├── define-events.js
│ │ ├── define-svg.js
│ │ ├── observed-attributes.js
│ │ └── observed-properties.js
├── render-content-element
│ ├── README.md
│ ├── package.json
│ └── src
│ │ ├── browser.js
│ │ ├── example.html
│ │ └── index.js
├── social-media-player-element
│ ├── README.md
│ ├── package.json
│ └── src
│ │ ├── browser.js
│ │ ├── example.html
│ │ ├── index.css
│ │ ├── index.js
│ │ └── lib
│ │ ├── define-youtube-events.js
│ │ └── observed-attributes.js
└── uid
│ ├── README.md
│ ├── package.json
│ └── src
│ ├── example.html
│ └── index.js
└── scripts
├── config
├── babel.config.js
└── rollup.config.js
├── templates
└── example.html
└── watch.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | indent_style = tab
7 | insert_final_newline = true
8 | trim_trailing_whitespace = true
9 |
10 | [{.*,*.{json,md,yml}}]
11 | indent_size = 2
12 | indent_style = space
13 |
14 | [*.md]
15 | trim_trailing_whitespace = false
16 |
17 | [{CONTRIBUTING.md,LICENSE.md}]
18 | indent_size = 3
19 |
20 | [{/packages/*/*.{js,map,mjs},**/node_modules/**}]
21 | charset = none
22 | end_of_line = none
23 | insert_final_newline = none
24 | trim_trailing_whitespace = none
25 | indent_style = none
26 | indent_size = none
27 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "env": {
4 | "browser": true,
5 | "es6": true,
6 | "node": true
7 | },
8 | "parser": "babel-eslint",
9 | "parserOptions": {
10 | "ecmaVersion": 2018,
11 | "impliedStrict": true,
12 | "sourceType": "module"
13 | },
14 | "extends": "eslint:recommended"
15 | }
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | package-lock.json
3 | *.log*
4 | .*
5 | !.editorconfig
6 | !.eslintrc
7 | !.gitignore
8 | !.stylelintrc
9 | !.travis.yml
10 | /packages/*/*[.js,.map,.mjs]
11 |
--------------------------------------------------------------------------------
/.stylelintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "stylelint-config-dev"
3 | }
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # https://docs.travis-ci.com/user/travis-lint
2 |
3 | language: node_js
4 |
5 | node_js:
6 | - 8
7 |
8 | install:
9 | - npm install --no-scripts
10 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Web Components
2 |
3 | You want to help? You rock! Now, take a moment to be sure your contributions
4 | make sense to everyone else.
5 |
6 | ## Reporting Issues
7 |
8 | Found a problem? Want a new feature?
9 |
10 | - See if your issue or idea has [already been reported].
11 | - Provide a [reduced test case] or a [live example].
12 |
13 | Remember, a bug is a _demonstrable problem_ caused by _our_ code.
14 |
15 | ## Submitting Pull Requests
16 |
17 | Pull requests are the greatest contributions, so be sure they are focused in
18 | scope and avoid unrelated commits.
19 |
20 | 1. To begin; [fork this project], clone your fork, and add our upstream.
21 | ```bash
22 | # Clone your fork of the repo into the current directory
23 | git clone git@github.com:YOUR_USER/web-components.git
24 |
25 | # Navigate to the newly cloned directory
26 | cd web-components
27 |
28 | # Assign the original repo to a remote called "upstream"
29 | git remote add upstream git@github.com:t7/web-components.git
30 |
31 | # Install the tools necessary for testing
32 | npm install
33 | ```
34 |
35 | 2. Create a branch for your feature or fix:
36 | ```bash
37 | # Move into a new branch for your feature
38 | git checkout -b feature/thing
39 | ```
40 | ```bash
41 | # Move into a new branch for your fix
42 | git checkout -b fix/something
43 | ```
44 |
45 | 3. If your code follows our practices, then push your feature branch:
46 | ```bash
47 | # Test current code
48 | npm test
49 | ```
50 | ```bash
51 | # Push the branch for your new feature
52 | git push origin feature/thing
53 | ```
54 | ```bash
55 | # Or, push the branch for your update
56 | git push origin update/something
57 | ```
58 |
59 | That’s it! Now [open a pull request] with a clear title and description.
60 |
61 | [already been reported]: https://github.com/t7/web-components/issues
62 | [fork this project]: https://github.com/t7/web-components/fork
63 | [live example]: https://codepen.io/pen
64 | [open a pull request]: https://help.github.com/articles/using-pull-requests/
65 | [reduced test case]: https://css-tricks.com/reduced-test-cases/
66 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | # CC0 1.0 Universal
2 |
3 | ## Statement of Purpose
4 |
5 | The laws of most jurisdictions throughout the world automatically confer
6 | exclusive Copyright and Related Rights (defined below) upon the creator and
7 | subsequent owner(s) (each and all, an “owner”) of an original work of
8 | authorship and/or a database (each, a “Work”).
9 |
10 | Certain owners wish to permanently relinquish those rights to a Work for the
11 | purpose of contributing to a commons of creative, cultural and scientific works
12 | (“Commons”) that the public can reliably and without fear of later claims of
13 | infringement build upon, modify, incorporate in other works, reuse and
14 | redistribute as freely as possible in any form whatsoever and for any purposes,
15 | including without limitation commercial purposes. These owners may contribute
16 | to the Commons to promote the ideal of a free culture and the further
17 | production of creative, cultural and scientific works, or to gain reputation or
18 | greater distribution for their Work in part through the use and efforts of
19 | others.
20 |
21 | For these and/or other purposes and motivations, and without any expectation of
22 | additional consideration or compensation, the person associating CC0 with a
23 | Work (the “Affirmer”), to the extent that he or she is an owner of Copyright
24 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and
25 | publicly distribute the Work under its terms, with knowledge of his or her
26 | Copyright and Related Rights in the Work and the meaning and intended legal
27 | effect of CC0 on those rights.
28 |
29 | 1. Copyright and Related Rights. A Work made available under CC0 may be
30 | protected by copyright and related or neighboring rights (“Copyright and
31 | Related Rights”). Copyright and Related Rights include, but are not limited
32 | to, the following:
33 | 1. the right to reproduce, adapt, distribute, perform, display, communicate,
34 | and translate a Work;
35 | 2. moral rights retained by the original author(s) and/or performer(s);
36 | 3. publicity and privacy rights pertaining to a person’s image or likeness
37 | depicted in a Work;
38 | 4. rights protecting against unfair competition in regards to a Work,
39 | subject to the limitations in paragraph 4(i), below;
40 | 5. rights protecting the extraction, dissemination, use and reuse of data in
41 | a Work;
42 | 6. database rights (such as those arising under Directive 96/9/EC of the
43 | European Parliament and of the Council of 11 March 1996 on the legal
44 | protection of databases, and under any national implementation thereof,
45 | including any amended or successor version of such directive); and
46 | 7. other similar, equivalent or corresponding rights throughout the world
47 | based on applicable law or treaty, and any national implementations
48 | thereof.
49 |
50 | 2. Waiver. To the greatest extent permitted by, but not in contravention of,
51 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
52 | unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright
53 | and Related Rights and associated claims and causes of action, whether now
54 | known or unknown (including existing as well as future claims and causes of
55 | action), in the Work (i) in all territories worldwide, (ii) for the maximum
56 | duration provided by applicable law or treaty (including future time
57 | extensions), (iii) in any current or future medium and for any number of
58 | copies, and (iv) for any purpose whatsoever, including without limitation
59 | commercial, advertising or promotional purposes (the “Waiver”). Affirmer
60 | makes the Waiver for the benefit of each member of the public at large and
61 | to the detriment of Affirmer’s heirs and successors, fully intending that
62 | such Waiver shall not be subject to revocation, rescission, cancellation,
63 | termination, or any other legal or equitable action to disrupt the quiet
64 | enjoyment of the Work by the public as contemplated by Affirmer’s express
65 | Statement of Purpose.
66 |
67 | 3. Public License Fallback. Should any part of the Waiver for any reason be
68 | judged legally invalid or ineffective under applicable law, then the Waiver
69 | shall be preserved to the maximum extent permitted taking into account
70 | Affirmer’s express Statement of Purpose. In addition, to the extent the
71 | Waiver is so judged Affirmer hereby grants to each affected person a
72 | royalty-free, non transferable, non sublicensable, non exclusive,
73 | irrevocable and unconditional license to exercise Affirmer’s Copyright and
74 | Related Rights in the Work (i) in all territories worldwide, (ii) for the
75 | maximum duration provided by applicable law or treaty (including future time
76 | extensions), (iii) in any current or future medium and for any number of
77 | copies, and (iv) for any purpose whatsoever, including without limitation
78 | commercial, advertising or promotional purposes (the “License”). The License
79 | shall be deemed effective as of the date CC0 was applied by Affirmer to the
80 | Work. Should any part of the License for any reason be judged legally
81 | invalid or ineffective under applicable law, such partial invalidity or
82 | ineffectiveness shall not invalidate the remainder of the License, and in
83 | such case Affirmer hereby affirms that he or she will not (i) exercise any
84 | of his or her remaining Copyright and Related Rights in the Work or (ii)
85 | assert any associated claims and causes of action with respect to the Work,
86 | in either case contrary to Affirmer’s express Statement of Purpose.
87 |
88 | 4. Limitations and Disclaimers.
89 | 1. No trademark or patent rights held by Affirmer are waived, abandoned,
90 | surrendered, licensed or otherwise affected by this document.
91 | 2. Affirmer offers the Work as-is and makes no representations or warranties
92 | of any kind concerning the Work, express, implied, statutory or
93 | otherwise, including without limitation warranties of title,
94 | merchantability, fitness for a particular purpose, non infringement, or
95 | the absence of latent or other defects, accuracy, or the present or
96 | absence of errors, whether or not discoverable, all to the greatest
97 | extent permissible under applicable law.
98 | 3. Affirmer disclaims responsibility for clearing rights of other persons
99 | that may apply to the Work or any use thereof, including without
100 | limitation any person’s Copyright and Related Rights in the Work.
101 | Further, Affirmer disclaims responsibility for obtaining any necessary
102 | consents, permissions or other rights required for any use of the Work.
103 | 4. Affirmer understands and acknowledges that Creative Commons is not a
104 | party to this document and has no duty or obligation with respect to this
105 | CC0 or use of the Work.
106 |
107 | For more information, please see
108 | http://creativecommons.org/publicdomain/zero/1.0/.
109 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Web Components [][Web Components]
2 |
3 | [![Build Status][cli-img]][cli-url]
4 | [![Issue Tracker][git-img]][git-url]
5 | [![Pull Requests][gpr-img]][gpr-url]
6 |
7 | This is a collection of [Web Components] developed at Genpact T7.
8 |
9 | ## Development
10 |
11 | To develop this project locally, you will need
12 | [Git v2 or higher](https://git-scm.com/downloads) and
13 | [Node v6 or higher](https://nodejs.org/en/download/current/) and comfortable
14 | access to a terminal or command prompt.
15 |
16 | To begin working on this project; clone this repository.
17 |
18 | ```bash
19 | git clone git@github.com:t7/web-components.git
20 | ```
21 |
22 | After navigating to the cloned repository, install this project’s dependencies.
23 |
24 | ```bash
25 | npm install
26 | ```
27 |
28 | Once the dependencies are installed, you can run the project locally.
29 |
30 | ```bash
31 | npm start
32 | ```
33 |
34 | Read [CONTRIBUTING.md](CONTRIBUTING.md) before contributing back to the project.
35 |
36 | [Web Components]: https://github.com/t7/web-components
37 |
38 | [cli-img]: https://img.shields.io/travis/t7/web-components/master.svg
39 | [cli-url]: https://travis-ci.org/t7/web-components
40 | [git-img]: https://img.shields.io/github/issues-raw/t7/web-components.svg
41 | [git-url]: https://github.com/t7/web-components/issues
42 | [gpr-img]: https://img.shields.io/github/issues-pr-raw/t7/web-components.svg
43 | [gpr-url]: https://github.com/t7/web-components/pulls
44 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "packages": [
3 | "packages/*"
4 | ],
5 | "version": "independent"
6 | }
7 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@t7/web-components",
3 | "description": "A collection of Web Components developed at Genpact T7",
4 | "author": "TandemSeven ",
5 | "license": "CC0-1.0",
6 | "repository": "t7/web-components",
7 | "homepage": "https://github.com/t7/web-components#readme",
8 | "bugs": "https://github.com/t7/web-components/issues",
9 | "scripts": {
10 | "bootstrap": "lerna bootstrap",
11 | "docs": "jsdoc -c .jsdocrc -d .gh-pages",
12 | "postinstall": "git clone --single-branch --branch gh-pages https://github.com/t7/web-components.git .gh-pages",
13 | "prestart": "npm run bootstrap",
14 | "test": "npm run test:eclint && npm run test:eslint && npm run test:stylelint",
15 | "test:eclint": "eclint check",
16 | "test:eslint": "eslint packages/*/src/**.js --cache --ignore-path .gitignore",
17 | "test:stylelint": "stylelint packages/*/src/**.css --cache",
18 | "start": "concurrently --raw \"npx upsite .gh-pages -p 8080 -c empty\" \"lerna exec --parallel -- node ../../scripts/watch.js\""
19 | },
20 | "engines": {
21 | "node": ">=8.0.0"
22 | },
23 | "devDependencies": {
24 | "@babel/core": "^7.4.4",
25 | "@babel/plugin-proposal-class-properties": "^7.4.4",
26 | "@babel/preset-env": "^7.4.4",
27 | "babel-eslint": "^10.0.1",
28 | "babel-plugin-import-postcss": "^1.2.0",
29 | "concurrently": "^4.1.0",
30 | "cssnano": "^4.1.10",
31 | "eclint": "^2.8.1",
32 | "eslint": "^5.16.0",
33 | "fse": "^4.0.1",
34 | "gzip-size": "^5.1.0",
35 | "lerna": "^3.13.4",
36 | "postcss-preset-env": "^6.6.0",
37 | "rollup": "^1.10.1",
38 | "rollup-plugin-babel": "^4.3.2",
39 | "rollup-plugin-commonjs": "^9.3.4",
40 | "rollup-plugin-node-resolve": "^4.2.3",
41 | "rollup-plugin-terser": "^4.0.4",
42 | "stylelint": "^10.0.1",
43 | "stylelint-config-dev": "^4.0.0"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/packages/accordion-list-element/README.md:
--------------------------------------------------------------------------------
1 | # Accordion List Element [][Accordion List Element]
2 |
3 | [![Build Status][cli-img]][cli-url]
4 | [![Issue Tracker][git-img]][git-url]
5 | [![Pull Requests][gpr-img]][gpr-url]
6 |
7 | [Accordion List Element] is a [Web Component] for containing a series of
8 | [Accordion Panel Elements] which can be controlled collectively. It will add up
9 | to 446 bytes to your project.
10 |
11 | **[Try it now](https://t7.github.io/web-components/accordion-list-element/)**
12 |
13 | ## Usage
14 |
15 | Add the Accordion List Element to your page.
16 |
17 | ```html
18 |
19 |
20 |
21 |
22 |
67 | domset(document.body, null,
68 | domset('h3', null,
69 | 'Hello, ', domset('strong', { title: 'Earthly Planet' },
70 | 'World'
71 | ), '!')
72 | );
73 |
74 | // append
75 | domset(document.body, null,
76 | domset('svg', { viewBox: '0 0 32 32' },
77 | domset('path', { d: 'M4 0l24 16L4 32' })
78 | )
79 | );
80 | ```
81 |
82 | ## Arguments
83 |
84 | ### id
85 |
86 | The first argument represents the Node being referenced or created. String
87 | arguments create new Elements using the string as the tag name.
88 |
89 | ```js
90 | // create using the "h3" string
91 | domset('h3');
92 |
93 | // create using the "svg" string
94 | domset('svg');
95 | ```
96 |
97 | ```js
98 | // use the created
99 | domset(document.createElement('h3'));
100 |
101 | // use the created
102 | domset(document.createElementNS('http://www.w3.org/2000/svg', 'svg'));
103 | ```
104 |
105 | ### attributes
106 |
107 | The second argument represents the properties or attributes being assigned to
108 | the element. When a name exists on the element as a property then the property
109 | is assigned. Otherwise, the attribute is assigned. Attributes with a `null`
110 | value are removed from the element.
111 |
112 | ```js
113 | // create using the "className" property
114 | domset('h3', { className: 'foo' });
115 | ```
116 |
117 | ```js
118 | // create using the "class" attribute
119 | domset('h3', { class: 'foo' });
120 | ```
121 |
122 | ```js
123 | // create with a click event using the "onclick" property
124 | domset('h3', { onclick(event) {} });
125 | ```
126 |
127 | ### children
128 |
129 | The third argument and all arguments afterward are children to be appended to
130 | the element.
131 |
132 | ```js
133 | // append "Hello World" as a text node to
134 | domset('h3', null, 'Hello World');
135 | ```
136 |
137 | ```js
138 | // append "Hello World" as 3 text nodes to
59 | document.body.append(
60 | domset('h3', null, 'Hello, ', domset('strong', { title: 'Earthly Planet' }, 'World'), '!')
61 | );
62 | ```
63 |
64 | ## Arguments
65 |
66 | ### element
67 |
68 | The first argument represents the Element being referenced or created. String
69 | arguments create new Elements using the string as the tag name.
70 |
71 | ```js
72 | // create using the "h3" string
73 | domset('h3');
74 | ```
75 |
76 | ```js
77 | // use the created
78 | domset(document.createElement('h3'));
79 | ```
80 |
81 | ### attributes
82 |
83 | The second argument represents the properties or attributes being assigned to
84 | the element. When a name exists on the element as a property then the property
85 | is assigned. Otherwise, the attribute is assigned. Attributes with a `null`
86 | value are removed from the element.
87 |
88 | ```js
89 | // create using the "className" property
90 | domset('h3', { className: 'foo' });
91 | ```
92 |
93 | ```js
94 | // create using the "class" attribute
95 | domset('h3', { class: 'foo' });
96 | ```
97 |
98 | ```js
99 | // create with a click event using the "onclick" property
100 | domset('h3', { onclick(event) {} });
101 | ```
102 |
103 | ### children
104 |
105 | The third argument and all arguments afterward are children to be appended to
106 | the element.
107 |
108 | ```js
109 | // append "Hello World" as a text node to
110 | domset('h3', null, 'Hello World');
111 | ```
112 |
113 | ```js
114 | // append "Hello World" as 3 text nodes to
22 |
23 | [Media Player Element] is designed for developers who want complete visual
24 | control over the component. It’s also for developers who want to hack at or
25 | extend the player without any fuss. The player itself does all the heavy
26 | lifting; semantic markup, accessibility management, language, fullscreen, text
27 | direction, providing pointer-agnostic scrubbable timelines, and lots of other
28 | cool sounding stuff.
29 |
30 |
3 | This text should be accessible to the user.
4 |
5 |
6 |
7 |
8 | This text should not be accessible to the user.
9 |
10 |
11 |
--------------------------------------------------------------------------------
/packages/render-content-element/src/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @name RenderContentElement
3 | * @class
4 | * @extends HTMLElement
5 | * @classdesc Return a new Render Content Element.
6 | * @returns {RenderContentElement~Instance}
7 | */
8 | /**
9 | * @typedef RenderContentElement~Instance
10 | * @property {Boolean} when - Indicates whether the {@link RenderContentElement} is accessible.
11 | */
12 |
13 | export default class RenderContentElement extends HTMLElement {
14 | constructor () {
15 | super();
16 |
17 | this.attachShadow({ mode: 'open' });
18 |
19 | this.slotElement = document.createElement('slot');
20 | }
21 |
22 | attributeChangedCallback (name, oldValue, newValue) {
23 | if (name === 'when') {
24 | const shouldBeShown = newValue !== null;
25 |
26 | if (shouldBeShown) {
27 | if (!this.slotElement.parentNode) {
28 | this.shadowRoot.appendChild(this.slotElement);
29 | }
30 | } else {
31 | if (this.slotElement.parentNode) {
32 | this.shadowRoot.removeChild(this.slotElement);
33 | }
34 | }
35 | }
36 | }
37 |
38 | get when () {
39 | return this.hasAttribute('when');
40 | }
41 |
42 | set when (value) {
43 | if (value) {
44 | this.setAttribute('when', '');
45 | } else {
46 | this.removeAttribute('when');
47 | }
48 | }
49 |
50 | static get observedAttributes () {
51 | return ['when'];
52 | }
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/packages/social-media-player-element/README.md:
--------------------------------------------------------------------------------
1 | # Social Media Player Element [][Social Media Player Element]
2 |
3 | [![Build Status][cli-img]][cli-url]
4 | [![Issue Tracker][git-img]][git-url]
5 | [![Pull Requests][gpr-img]][gpr-url]
6 |
7 | [Social Media Player Element] is a [Web Component] for creating tiny,
8 | responsive, international, accessible, easily customizable media players that
9 | also support YouTube video IDs. It will add up to 4.72 kB to your project.
10 |
11 | **[Try it now](https://t7.github.io/web-components/social-media-player-element/)**
12 |
13 | ---
14 |
15 | [Social Media Player Element] can be controlled with any pointer or keyboard,
16 | whether it’s to play, pause, move across the timeline, mute, unmute, adjust the
17 | volume, enter or leave fullscreen, or download the source.
18 |
19 |
20 |
21 |
22 |
23 | [Social Media Player Element] is designed for developers who want complete
24 | visual control over the component. It’s also for developers who want to hack at
25 | or extend the player without any fuss. It is itself an extension of the
26 | [Media Player Element]. The player itself does all the heavy lifting; semantic
27 | markup, accessibility management, language, fullscreen, text direction,
28 | providing pointer-agnostic scrubbable timelines, and lots of other cool
29 | sounding stuff.
30 |
31 |