Skip to content

Commit c46f9c1

Browse files
committed
porting old components from ember-styleguide
1 parent 5f83d29 commit c46f9c1

File tree

523 files changed

+27126
-12202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

523 files changed

+27126
-12202
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
root = true
66

7+
78
[*]
89
end_of_line = lf
910
charset = utf-8

.ember-cli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
Setting `disableAnalytics` to true will prevent any data from being sent.
77
*/
8-
"disableAnalytics": false
8+
"disableAnalytics": true
99
}

.eslintrc.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
'use strict';
2-
31
module.exports = {
42
root: true,
5-
parser: 'babel-eslint',
63
parserOptions: {
7-
ecmaVersion: 2018,
8-
sourceType: 'module',
9-
ecmaFeatures: {
10-
legacyDecorators: true
11-
}
4+
ecmaVersion: 2017,
5+
sourceType: 'module'
126
},
137
plugins: [
148
'ember'
@@ -21,13 +15,14 @@ module.exports = {
2115
browser: true
2216
},
2317
rules: {
24-
'ember/no-jquery': 'error'
18+
'no-useless-escape': 'off'
2519
},
2620
overrides: [
2721
// node files
2822
{
2923
files: [
3024
'.eslintrc.js',
25+
'.stylelintrc.js',
3126
'.template-lintrc.js',
3227
'ember-cli-build.js',
3328
'index.js',
@@ -43,7 +38,8 @@ module.exports = {
4338
'tests/dummy/app/**'
4439
],
4540
parserOptions: {
46-
sourceType: 'script'
41+
sourceType: 'script',
42+
ecmaVersion: 2015
4743
},
4844
env: {
4945
browser: false,

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
/node_modules/
1010

1111
# misc
12-
/.env*
13-
/.pnp*
1412
/.sass-cache
1513
/connect.lock
1614
/coverage/
@@ -23,3 +21,5 @@
2321
/.node_modules.ember-try/
2422
/bower.json.ember-try
2523
/package.json.ember-try
24+
25+
.vscode

.netlifyredirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* /index.html 200

.stylelintrc.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
extends: 'stylelint-config-standard',
3+
plugins: [
4+
'stylelint-declaration-strict-value',
5+
'stylelint-order',
6+
'stylelint-scss'
7+
],
8+
rules: {
9+
// Disables this rule to allow case agnostic color hex values
10+
'color-hex-case': null,
11+
// Require the long version of hex colors
12+
'color-hex-length': 'long',
13+
// Disallow ids
14+
'selector-max-id': 0,
15+
// Enforce alphabetical ordering of properties
16+
'order/properties-alphabetical-order': true,
17+
// Require that color, background-color, etc use variables for colors, instead of direct values
18+
'scale-unlimited/declaration-strict-value': [
19+
['/color/'] // We can enforce variables for font-size, margin, etc as well by adding here
20+
],
21+
// Enforce that variables are all lowercase and dasherized
22+
'scss/dollar-variable-pattern': '^[a-z][a-z-]+$'
23+
}
24+
};

.template-lintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

33
module.exports = {
4-
extends: 'octane'
4+
extends: 'recommended',
55
};

.travis.yml

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,49 @@ language: node_js
33
node_js:
44
# we recommend testing addons with the same minimum supported node version as Ember CLI
55
# so that your addon works for all apps
6-
- "10"
6+
- "8"
77

8+
sudo: false
89
dist: trusty
910

1011
addons:
1112
chrome: stable
1213

1314
cache:
14-
directories:
15-
- $HOME/.npm
15+
yarn: true
1616

1717
env:
1818
global:
1919
# See https://git.io/vdao3 for details.
2020
- JOBS=1
2121

22-
branches:
23-
only:
24-
- master
25-
# npm version tags
26-
- /^v\d+\.\d+\.\d+/
27-
2822
jobs:
29-
fast_finish: true
23+
fail_fast: true
3024
allow_failures:
3125
- env: EMBER_TRY_SCENARIO=ember-canary
3226

3327
include:
3428
# runs linting and tests with current locked deps
29+
3530
- stage: "Tests"
3631
name: "Tests"
3732
script:
38-
- npm run lint
39-
- npm run test:ember
40-
41-
- stage: "Additional Tests"
42-
name: "Floating Dependencies"
43-
install:
44-
- npm install --no-package-lock
45-
script:
46-
- npm run test:ember
33+
- yarn lint:hbs
34+
- yarn lint:js
35+
- yarn test
4736

4837
# we recommend new addons test the current and previous LTS
4938
# as well as latest stable release (bonus points to beta/canary)
50-
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
51-
- env: EMBER_TRY_SCENARIO=ember-lts-3.16
39+
- stage: "Additional Tests"
40+
env: EMBER_TRY_SCENARIO=ember-lts-2.18
41+
- env: EMBER_TRY_SCENARIO=ember-lts-3.4
5242
- env: EMBER_TRY_SCENARIO=ember-release
5343
- env: EMBER_TRY_SCENARIO=ember-beta
5444
- env: EMBER_TRY_SCENARIO=ember-canary
5545
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
56-
- env: EMBER_TRY_SCENARIO=ember-classic
46+
47+
before_install:
48+
- npm config set spin false
5749

5850
script:
5951
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO

CODE_OF_CONDUCT.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The Ember team and community are committed to everyone having a safe and inclusive experience.
2+
3+
Our Community Guidelines / Code of Conduct can be found here:
4+
5+
https://emberjs.com/guidelines/
6+
7+
For a history of updates, see the page history here:
8+
9+
https://github.com/emberjs/website/commits/master/source/guidelines.html.erb

addon/components/es-accordion.js

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import Component from '@ember/component';
2+
import layout from '../templates/components/es-accordion';
3+
import {
4+
get,
5+
getProperties,
6+
set,
7+
} from '@ember/object';
8+
import {
9+
isPresent,
10+
} from '@ember/utils';
11+
import { computed } from '@ember/object';
12+
import {
13+
A,
14+
} from '@ember/array';
15+
16+
export default Component.extend({
17+
layout,
18+
19+
classNames: ['accordion-group'],
20+
21+
activeItem: null,
22+
focusIndex: null,
23+
accordionItemIndexes: null,
24+
25+
accordionState: computed('activeItem', 'focusIndex', function() {
26+
const {
27+
activeItem,
28+
focusIndex,
29+
actions,
30+
} = getProperties(this, [
31+
'activeItem',
32+
'focusIndex',
33+
'actions',
34+
]);
35+
36+
return {
37+
activeItem,
38+
focusIndex,
39+
setActiveItem: actions.setActiveItem.bind(this),
40+
setFocusIndex: actions.setFocusIndex.bind(this),
41+
registerIndex: actions.registerIndex.bind(this),
42+
};
43+
}),
44+
45+
init() {
46+
this._super(...arguments);
47+
48+
set(this, 'accordionItemIndexes', []);
49+
},
50+
51+
keyDown(e) {
52+
const keyCode = get(e, 'keyCode');
53+
const focusIndex = get(this, 'focusIndex');
54+
55+
if (isPresent(focusIndex)) {
56+
const targetIndex = this._resolveTargetItemIndex(keyCode);
57+
58+
set(this, 'activeItem', targetIndex);
59+
}
60+
},
61+
62+
_resolveTargetItemIndex(keyCode) {
63+
const {
64+
accordionItemIndexes,
65+
activeItem,
66+
focusIndex,
67+
} = getProperties(this, [
68+
'accordionItemIndexes',
69+
'activeItem',
70+
'focusIndex',
71+
]);
72+
const first = Math.min(...accordionItemIndexes);
73+
const last = Math.max(...accordionItemIndexes);
74+
let itemIndexOfIndex = A(accordionItemIndexes).indexOf(activeItem);
75+
let targetIndex;
76+
77+
switch (keyCode) {
78+
case 38:
79+
if (activeItem === null || itemIndexOfIndex === -1) {
80+
targetIndex = focusIndex;
81+
} else if (activeItem === first) {
82+
targetIndex = last;
83+
} else {
84+
itemIndexOfIndex--
85+
targetIndex = accordionItemIndexes[itemIndexOfIndex];
86+
}
87+
break;
88+
case 40:
89+
if (activeItem === null || itemIndexOfIndex === -1) {
90+
targetIndex = focusIndex;
91+
} else if (activeItem === last) {
92+
targetIndex = first;
93+
} else {
94+
itemIndexOfIndex++
95+
targetIndex = accordionItemIndexes[itemIndexOfIndex];
96+
}
97+
break;
98+
case 36:
99+
targetIndex = first;
100+
break;
101+
case 35:
102+
targetIndex = last;
103+
break;
104+
case 13:
105+
case 32:
106+
if (activeItem !== focusIndex) {
107+
targetIndex = focusIndex;
108+
} else {
109+
targetIndex = null;
110+
}
111+
break;
112+
default:
113+
targetIndex = activeItem;
114+
}
115+
116+
return targetIndex;
117+
},
118+
119+
actions: {
120+
setActiveItem(accordionItemIndex) {
121+
return set(this, 'activeItem', accordionItemIndex);
122+
},
123+
124+
setFocusIndex(accordionItemIndex) {
125+
set(this, 'focusIndex', accordionItemIndex);
126+
},
127+
128+
registerIndex(accordionItemIndex) {
129+
get(this, 'accordionItemIndexes').push(accordionItemIndex);
130+
},
131+
},
132+
});

0 commit comments

Comments
 (0)