73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/scripts/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # ------------------------------------------------------------------------------
4 | # CREATES A LOCAL VERSION OF THE DEMO/DOCS BUILD
5 | #
6 | # The `scripts/ghp.sh` file is run by Travis CI to build the docs/demo pages and
7 | # deploy those pages to by pushing to a special Github repo.
8 | #
9 | # This script has a small subset of the build steps. It can be used for fast
10 | # local builds to simulate the production site. Alternatively, it can be used
11 | # to create a local build that can be pushed to the docs site if a hotfix is
12 | # needed and Travis is taking too long.
13 | #
14 | # CONFIGURING YOUR PROJECT:
15 | #
16 | # Your project should include at least the following files, in addition to any
17 | # code for the project itself:
18 | #
19 | # project/
20 | # |- scripts/build.sh
21 | # |- node_modules/
22 | # |- bower_components/
23 | # |- bower.json
24 | # |- polymer.json
25 | # |- package.json
26 | #
27 | # package.json requirements:
28 | # - `bower` and `polymer-cli` (1.3.0+) must be installed as devDependencies
29 | #
30 | # bower.json requirements:
31 | # - the repo name must be in the "name" field
32 | #
33 | # polymer.json requirements:
34 | # - the build must be configured, with all required sources listed
35 | #
36 | # Additionally, the `build/` directory should be empty and added to `.gitignore`
37 | # to ensure nothing important is overwritten.
38 | #
39 | # HOW TO USE IT:
40 | #
41 | # These commands should be run from the root of your project.
42 | #
43 | # 1. This file should be saved in your project as `scripts/build.sh`.
44 | # 2. Run `yarn install` or `npm install` (your choice)
45 | # 3. Run `bower install`
46 | # 4. Run `./scripts/build.sh`
47 | # ------------------------------------------------------------------------------
48 |
49 | # Find repo name from the bower file
50 | REPO_NAME=$(grep "name" bower.json | sed 's/"name": "//' | sed 's/",//' | sed -e 's/^[[:space:]]*//')
51 |
52 | echo "Starting build for $REPO_NAME"
53 |
54 | # Bower install theme dependencies
55 | ./node_modules/.bin/bower install px-theme px-dark-theme px-dark-demo-theme
56 |
57 | # Run polymer build to transpile code. The output will be placed in the
58 | # `build/unbundled` directory
59 | ./node_modules/.bin/polymer build
60 |
61 | # Open the build directory
62 | cd build/
63 |
64 | # Rename unbundled --> $REPO_NAME, move all the bower_components/ up one level
65 | # so they're beside to $REPO_NAME
66 | mv unbundled $REPO_NAME
67 | rm -rf "$REPO_NAME/bower_components/$REPO_NAME/"
68 | find "$REPO_NAME/bower_components" -mindepth 1 -maxdepth 1 -print0 | xargs -0 -I {} mv {} .
69 | rm -rf "$REPO_NAME/bower_components/"
70 |
71 | # Add the redirect
72 | # Note: We are not overwriting the component's documentation `index.html` file
73 | # here, we are making sure that http://url/px-something/ redirects to
74 | # http://url/px-something/px-something/, where the demo page is installed
75 | echo "" > index.html
76 |
77 | echo ""
78 | echo "================================================"
79 | echo "Build finished in $(pwd)"
80 | echo "================================================"
81 | echo ""
82 |
--------------------------------------------------------------------------------
/css/px-context-browser-panel-styles.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
22 |
23 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | dist: trusty
3 | language: node_js
4 | node_js:
5 | - stable
6 | branches:
7 | except:
8 | - gh-pages
9 | addons:
10 | firefox: latest
11 | apt:
12 | sources:
13 | - google-chrome
14 | packages:
15 | - google-chrome-stable
16 | before_script:
17 | - yarn add polymer-cli
18 | - polymer install --variants
19 | script:
20 | - xvfb-run wct --skip-plugin sauce
21 | - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct --plugin sauce --skip-plugin
22 | local; fi
23 | after_success:
24 | - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then openssl aes-256-cbc -k "$DEPLOYSECRET"
25 | -in deploy.enc -out deploy_key -d; fi
26 | - cd $TRAVIS_BUILD_DIR/scripts
27 | - chmod 755 ghp.sh
28 | - "./ghp.sh"
29 | env:
30 | global:
31 | - secure: aZpqcoQqAkts03dcEOlCbxlxT3nzL/w7y1+/9PaS2wqep+MoqLOF1eH8ACIlEnbekd5ppp7jefb2aBxMdGrtN+Ft9d0ko/k48di5v/812pIgiU+FLGOu7VmRPaOvOJqXA0QJ+5Mwai9Q7WBEDt7KLjv+sevw75C1Ub10RHlkrRJ5QbC/NH3vjAPfgYdhu6Y4MeUx0E4QFNS7hOXBPH4BnR7XQ6vFkgbZdRZlLO0Nqy3jHyOgmi9I62gUN12D3sb8LWe81VVfW6/B2ixwfLwr23FEwEnfidcBMU7zxkqf/cG5aHlCFnDe72NFmi46EIZnKp5C0AZdbO0Mo2J7/DlawJ/dPgfnK9aOZzf2drk4I6B1An4EzwSbynqnDTYr8odigtRI/B0teylhNjwTmphkVjjyK9GUVV81orWyewm89/BQrxtDMcquCGqwdeBrkVUFdYDQtZHyKm3qKcPF41JkxEPvSbm21GqUalPShRVRl+Gzzr0QR+ucPcQ01F/nc0o8m232Dx27cRYG24+P2UcoOLBs1zoiaa9lo8gL3pXIq+Vw3nPlH7jNnYvZYZm08jzAaO7y9puFyi8NOARdR3M1gQ3/owAyDCXJ8GwSN0TbP8sCOL7qL0bzacwbAn2EgxPmfhOjvFu6sgBsY0Pld1gayNUzfSh0hFFj7jw1Xa+cCsY=
32 | - secure: Y/LIdgyBJ/arwgccc4LlimTRjIa9+b7GxhWmhis4/sqljAHU07XXGEEGAn065fRpAyKcs8Q3lz6Fb6swib1RvZfwZD72WXOFbimegS02BHbO6n/wYUZVfZHPQMpRh/l2RX5qXCUWY6JwABKhX6TClfJnctLKCh48nL7nEC53OluUm98/l6XlfG4FNYsgO3P1dm/i08m+tslRX8vLImmNXXwPFUGzWbdFHy4KMxpUAYPBJqGHTeCFP641sDaZAnyxESNdxwReZGNz4I7adRaPgDo7WBodCBazSuCt3PIHqcW3xJSHi7nOVcm8GXoEi/CBQfCbIqOzG/GusyAhuHOsRbG6WudIn6qSpe8uqJXFYN7GdHJnJFbr+TvujOv16D+oW8l3rCzkl2Dng4S2pKC0erFuOBGNgNfeZkELcojI6ombezUr+2Nwn7rGdrB3j1swee6ByP4wmlFIHMD/IkANoVh9nqVaAARumZGJ/qlgGa9JHjkZX4b15Ma8KG0TvSOzaBJaatbJH1ESo3Yn0BayGnO60ztMtZyxCJLju9bc+rOL+8/nv3pTFrYQ4PQOBCPJwg+/H5NGyp0I8JpburAu/vWZpqSLTck5CYsfesX0EzdR6RUbaKV2ef/kKKMt9VqhEywONF9OdEAywoBOiXkZB0YZAUXpSEK7hAU4DoGz4GE=
33 | - secure: f+NHiy+4XBPb5aIGfk683k6o4GAdp3Lzhjtn+dy5IqCXvsrMSW1oA982qdHfJfALltTnrul8pwvPm3kY1wimYcsGErQEP9KWgwldLbiQVdPHR+kM2vg1hJAuyvb643XNTBBoi+8B/EEazXAIz7Zp3Y2mPd02vVfBM0QYQ3eYZC5MkUpx3G9iNHI8Kr9kwNFOQXdUPkiB5fOXVlmO0cPM5XynHDVnI1k3Y1N5ouLP6RoYFMlwDXBY1ifb4KyH09qZYhCiTnpDC1CSLGmB/5YFYm4b9U0vO80YYxG6MBJvg8LcE5Yvtr4qip7jDHL3MA3IOKRLtNssKTejX8Z+Dhu5yERlhxf6MSIeKiiPE9rEehvZTbOo2L8mu0653KCJ4EXibPPjl9piNqt/opGQpFpWJpFSeUruP3MDh79d0MS51RURCOnsmWJNE4TRPqvKLA/4fHPhgky9E9vta/98YllFkiL+UIOwjYadVZMNQi/z4DpvX5ABO4B0aPHizxB3fWEL433ixpnZaFE7TnCCfFKdsNzx5ZmcBfkDs0Wjf7j7sSjxsq2ClHzM1siHCTQp9SElxsJLb7N3QPgPhcCt+ne33HFrN7Hv1+QfiK1Rs0sHUhuWGZMYLljBHD0l9fcSNwPGuuHVvl1c6Evyshuwhg46TW7OxrK4s4l7zD4vFvSpRFs=
34 | - secure: h/PPgMOSgAIv6b3D5PCm11ZlSNIiK98u6dcOTOAn2coN2WpSEqJTxDLQuzOovngX0liMr3e40aydeb3IOx168bcdnFeDN/kmxDVTbcYbgkxm7staJaVpEzi3jLG1vaa03xeLxxLor2g4YxvzrHuzV2Cjy4vqKqjSBkUhdUbj1sJQbz6aL9B0N9vReEypFKWZ3kKphuy17XWEqGF64b6s17yFDjTg20BUSqZYeGR1CAJE2QqcKXNSo7Kv84TqDIipP67vhRaFywBCk0YpCsSGx7ur58P3BOPQLOOArcXSEf2kqg7HenqOwmR0n2yHPDLicjr3L7VtjL85j94xM8dGkPiZwt9ogwO+kNlVkmRrgwCb1LuKMJUCDpXC7YVcOFtEJ955pl4rBvnYEV0Rs58HTqqCp1R4NE0yKVDIXsLAjzLRAISiwTfb0UDZWI2u3pI6KQNGHRVG27J/CZfmWxZg+WdiL8nV0P4ay2Ov0vjuZ3SWbVwrSpHRYEuO+BjrPTfROAvu+Q2SBYsEJRkqf8yzVhktdfL3bKOA5Ahchy7ivRPJpXZvaTNvQWUmj/PcIGE+egwGRyNlNzGjWdKXcZULI3ihKdSBKdwmbSNL9kN1+Pvp3T1i7avwKYOOOSSOQkdjUZhGm7dkMpNU7R8SYXPEVr0LmC2Az6bGihfG9j4+e3Q=
35 |
--------------------------------------------------------------------------------
/css/px-context-browser-header-styles.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
22 |
23 |
--------------------------------------------------------------------------------
/px-context-browser-filter.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
112 |
113 |
--------------------------------------------------------------------------------
/css/px-context-browser-item-styles.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
22 |
23 |
--------------------------------------------------------------------------------
/px-context-browser-favorited-temp.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
117 |
--------------------------------------------------------------------------------
/sass/px-context-browser-item.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, General Electric
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // Settings
18 | @import "px-defaults-design/_settings.defaults.scss";
19 |
20 | // Generic
21 | @import "px-normalize-design/_generic.normalize-mini.scss";
22 | @import "px-box-sizing-design/_generic.box-sizing.scss";
23 |
24 | // Base
25 | @import "px-headings-design/_base.headings.scss";
26 |
27 | // Component
28 | :host {
29 | display: flex;
30 | height: calculateRem(30px);
31 | color: var(--px-context-browser-item-text-color, black);
32 | transition: background-color .2s ease-in-out;
33 | }
34 |
35 | .context-browser-item {
36 | flex: 1 1 auto;
37 | display: flex;
38 | align-items: center;
39 | cursor: pointer;
40 | min-width: 0;
41 | }
42 |
43 | :host([style-as-favorite]) {
44 | height: calculateRem(60px);
45 | }
46 |
47 | :host(:hover),
48 | :host(:focus) {
49 | background-color: var(--px-context-browser-item-background-color--hover, whitesmoke);
50 | }
51 |
52 | :host([collapsed]:hover),
53 | :host([collapsed]:focus) {
54 | background-color: transparent;
55 | }
56 | // In collapsed mode, show hover color on active (e.g. on pressed interaction)
57 | :host([collapsed]:active) {
58 | background-color: var(--px-context-browser-item-background-color--hover, whitesmoke);
59 | }
60 |
61 | :host(:focus) {
62 | outline: none;
63 | }
64 |
65 | :host([selected]),
66 | :host([selected][collapsed]) {
67 | background-color: var(--px-context-browser-item-background-color--selected, steelblue);
68 | color: var(--px-context-browser-item-text-color--selected, white);
69 | }
70 |
71 | .context-browser-text {
72 | display: block;
73 | width: 100%;
74 | flex: 1 1 auto;
75 | padding-left: calculateRem(15px);
76 | padding-right: calculateRem(15px);
77 | cursor: pointer;
78 | user-select: none;
79 | min-width: 0;
80 | }
81 |
82 | .context-browser-text__label {
83 | white-space: nowrap;
84 | overflow: hidden;
85 | text-overflow: ellipsis;
86 | }
87 |
88 | .context-browser-text__breadcrumbs {
89 | color: var(--px-context-browser-item-breadcrumbs-color, gray);
90 | white-space: nowrap;
91 | overflow: hidden;
92 | text-overflow: ellipsis;
93 | }
94 |
95 | :host([selected]) .context-browser-text__breadcrumbs {
96 | color: var(--px-context-browser-item-breadcrumbs-color--selected, white);
97 | }
98 |
99 | .actions {
100 | margin-left: auto;
101 | opacity: 0;
102 | transition: opacity .2s ease-in-out;
103 | display: none;
104 | flex: 0 0 auto;
105 | }
106 | :host([style-as-favorite]) .actions {
107 | display: flex;
108 | opacity: 1;
109 | }
110 | :host(:hover) .actions,
111 | :host(:focus) .actions,
112 | :host([selected]) .actions {
113 | display: flex;
114 | opacity: 1;
115 | }
116 | :host([collapsed]:hover) .actions,
117 | :host([collapsed]:focus) .actions,
118 | :host([selected][collapsed]) .actions {
119 | display: none;
120 | }
121 | .action {
122 | width: calculateRem(20px);
123 | height: calculateRem(20px);
124 | margin-left: calculateRem(5px);
125 | margin-right: calculateRem(5px);
126 | cursor: pointer;
127 | color: var(--px-context-browser-icon-stroke, dimgray);
128 | }
129 | :host([selected]) .action {
130 | color: var(--px-context-browser-icon-stroke--item-selected, white);;
131 | }
132 | // For the default context browser, the last .action isn't the last-child because
133 | // of dom-ifs, it's 3rd-to-last
134 | .action:nth-last-child(3) {
135 | margin-right: calculateRem(15px);
136 | }
137 | // For the favorites context browser, there's only one .action
138 | :host([style-as-favorite]) .action {
139 | margin-right: calculateRem(15px);
140 | }
141 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | * Copyright (c) 2018, General Electric
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | 'use strict';
19 | const path = require('path');
20 | const gulp = require('gulp');
21 | const pkg = require('./package.json');
22 | const $ = require('gulp-load-plugins')();
23 | const gulpSequence = require('gulp-sequence');
24 | const importOnce = require('node-sass-import-once');
25 | const stylemod = require('gulp-style-modules');
26 | const browserSync = require('browser-sync').create();
27 | const gulpif = require('gulp-if');
28 | const combiner = require('stream-combiner2');
29 | const bump = require('gulp-bump');
30 | const argv = require('yargs').argv;
31 | const exec = require('child_process').exec;
32 | const { ensureLicense } = require('ensure-px-license');
33 |
34 | const sassOptions = {
35 | importer: importOnce,
36 | importOnce: {
37 | index: true,
38 | bower: true
39 | }
40 | };
41 |
42 | gulp.task('clean', function() {
43 | return gulp.src(['.tmp', 'css'], { read: false })
44 | .pipe($.clean());
45 | });
46 |
47 | function handleError(err) {
48 | console.log(err.toString());
49 | this.emit('end');
50 | }
51 |
52 | function buildCSS() {
53 | return combiner.obj([
54 | $.sass(sassOptions),
55 | $.autoprefixer({
56 | browsers: ['last 2 versions'],
57 | cascade: false,
58 | flexbox: false
59 | }),
60 | gulpif(!argv.debug, $.cssmin())
61 | ]).on('error', handleError);
62 | }
63 |
64 | gulp.task('sass', function() {
65 | return gulp.src(['./sass/*.scss'])
66 | .pipe(buildCSS())
67 | .pipe(stylemod({
68 | moduleId(file) {
69 | return path.basename(file.path, path.extname(file.path)) + '-styles';
70 | }
71 | }))
72 | .pipe(ensureLicense())
73 | .pipe(gulp.dest('css'))
74 | .pipe(browserSync.stream({ match: 'css/*.html' }));
75 | });
76 |
77 | gulp.task('watch', function() {
78 | gulp.watch(['sass/*.scss'], ['sass']);
79 | });
80 |
81 | gulp.task('serve', function() {
82 | browserSync.init({
83 | port: 8080,
84 | notify: false,
85 | reloadOnRestart: true,
86 | logPrefix: `${pkg.name}`,
87 | https: false,
88 | server: ['./', 'bower_components'],
89 | });
90 |
91 | gulp.watch(['css/*-styles.html', '*.html', '*.js', 'demo/*.html']).on('change', browserSync.reload);
92 | gulp.watch(['sass/*.scss'], ['sass']);
93 | });
94 |
95 | gulp.task('bump:patch', function() {
96 | gulp.src(['./bower.json', './package.json'])
97 | .pipe(bump({ type: 'patch' }))
98 | .pipe(gulp.dest('./'));
99 | });
100 |
101 | gulp.task('bump:minor', function() {
102 | gulp.src(['./bower.json', './package.json'])
103 | .pipe(bump({ type: 'minor' }))
104 | .pipe(gulp.dest('./'));
105 | });
106 |
107 | gulp.task('bump:major', function() {
108 | gulp.src(['./bower.json', './package.json'])
109 | .pipe(bump({ type: 'major' }))
110 | .pipe(gulp.dest('./'));
111 | });
112 |
113 | gulp.task('license', function() {
114 | return gulp.src(['./**/*.{html,js,css,scss}', '!./node_modules/**/*', '!./bower_components?(-1.x)/**/*'])
115 | .pipe(ensureLicense())
116 | .pipe(gulp.dest('.'));
117 | });
118 |
119 | gulp.task('default', function(callback) {
120 | gulpSequence('clean', 'sass', 'generate-api', 'license')(callback);
121 | });
122 |
123 | /**
124 | * Special task for Polymer component repos. Analyzes the component source code
125 | * and generates documentation in `[component-name]-api.json`.
126 | */
127 | gulp.task('generate-api', function (cb) {
128 | exec(`node_modules/.bin/polymer analyze ${pkg.name}.html > ${pkg.name}-api.json`, function(err, stdout, stderr) {
129 | console.log(stdout);
130 | console.log(stderr);
131 | cb(err);
132 | });
133 | });
134 |
--------------------------------------------------------------------------------
/scripts/ghp.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Exit with nonzero exit code if anything fails
4 | set -e
5 |
6 | # ------------------------------------------------------------------------------
7 | # CONFIGURE SCRIPT
8 | # ------------------------------------------------------------------------------
9 |
10 | # Set our source branch (where we'll build from) and our target branch (where we
11 | # want to send the build page to)
12 | SOURCE_BRANCH="master"
13 | TARGET_BRANCH="gh-pages"
14 | REPO=`git config remote.origin.url`
15 |
16 | # Find out our repo name from the bower file
17 | REPO_NAME=$(grep "name" bower.json | sed 's/"name": "//' | sed 's/",//' | sed -e 's/^[[:space:]]*//')
18 | echo "repo name is $REPO_NAME"
19 |
20 | # We get the URL in this format: "https://github.com/PredixDev/px-something"
21 | # First, we need to replace https-style remote URL with a SSH-style remote
22 | # URL we can push to below
23 | SSH_GIT=${REPO/https:\/\/github.com\//git@github.com:}
24 |
25 | # Now, the URL is in this format: "git@github.com:PredixDev/px-something"
26 | # Next, replace `PredixDev` Github organization with `predix-ui` so configure
27 | # the correct remote to push to.
28 | # The resulting URL will be: "git@github.com:predix-ui/px-something"
29 | SSH_GIT_PREDIXUI=${SSH_GIT/:PredixDev\//:predix-ui\/}
30 |
31 | # Prep git credentials
32 | GIT_USER_NAME="Travis CI"
33 | GIT_USER_EMAIL="PredixtravisCI@ge.com"
34 | GIT_COMMIT_MESSAGE="[Travis] Rebuild documentation (commit: $TRAVIS_COMMIT)"
35 |
36 | # Set git credentials
37 | git config user.name $GIT_USER_NAME
38 | git config user.email $GIT_USER_EMAIL
39 |
40 | # ------------------------------------------------------------------------------
41 | # CHECK IF BUILD SHOULD RUN
42 | # ------------------------------------------------------------------------------
43 |
44 | # Check if this CI run should run a deploy. We should only deploy if this CI run
45 | # is not a pull request and if this CI run is from the master branch.
46 | if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
47 | echo "Skipping deploy; just doing a build."
48 | exit 0
49 | fi
50 |
51 | # ------------------------------------------------------------------------------
52 | # BUILD
53 | # ------------------------------------------------------------------------------
54 |
55 | # Ensure we're in the build directory
56 | cd $TRAVIS_BUILD_DIR
57 |
58 | # Bower install theme dependencies
59 | ./node_modules/.bin/bower install px-theme px-dark-theme px-dark-demo-theme
60 |
61 | # Run polymer build to transpile code. The output will be placed in the
62 | # `build/unbundled` directory
63 | ./node_modules/.bin/polymer build
64 |
65 | # ------------------------------------------------------------------------------
66 | # MOVE FILES TO PREP FOR DEPLOY
67 | # ------------------------------------------------------------------------------
68 |
69 | # Open the build directory
70 | cd build/
71 |
72 | # Rename unbundled --> $REPO_NAME, move all the bower_components/ up one level
73 | # so they're beside to $REPO_NAME
74 | mv unbundled $REPO_NAME
75 | rm -rf "$REPO_NAME/bower_components/$REPO_NAME/"
76 | find "$REPO_NAME/bower_components" -mindepth 1 -maxdepth 1 -print0 | xargs -0 -I {} mv {} .
77 | rm -rf "$REPO_NAME/bower_components/"
78 |
79 | # Add the redirect
80 | # Note: We are not overwriting the component's documentation `index.html` file
81 | # here, we are making sure that http://url/px-something/ redirects to
82 | # http://url/px-something/px-something/, where the demo page is installed
83 | echo "" > index.html
84 |
85 | # Make sure the deploy key and node modules aren't checked into the build
86 | touch .gitignore
87 | echo "deploy_key" >> .gitignore
88 | echo "node_modules/" >> .gitignore
89 |
90 | # ------------------------------------------------------------------------------
91 | # GIT PUSH TO REMOTES
92 | # ------------------------------------------------------------------------------
93 |
94 | # Initialize a fresh git repo in this subdirectory we'll commit to
95 | git init .
96 |
97 | # Checkout a new orphan brach to build on
98 | git checkout --orphan $TARGET_BRANCH
99 |
100 | # Add and commit changes
101 | git add -A . >/dev/null
102 | echo "git add done"
103 | git commit -m "${GIT_COMMIT_MESSAGE}" >/dev/null
104 | echo "git commit done"
105 |
106 | # Prep the ssh key we'll use to deploy
107 | eval `ssh-agent -s`
108 | chmod 0400 $TRAVIS_BUILD_DIR/deploy_key
109 |
110 | # Push to predix-ui/repo `gh-pages` branch (force to override out-of-date refs)
111 | ssh-add $TRAVIS_BUILD_DIR/deploy_key
112 | git push $SSH_GIT_PREDIXUI $TARGET_BRANCH --force
113 |
114 | # Wait for Github Pages to rebuild and drop the cloudflare cache
115 |
116 |
117 |
--------------------------------------------------------------------------------
/css/px-context-browser-styles.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
22 |
23 |
--------------------------------------------------------------------------------
/sass/px-context-browser.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, General Electric
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // Settings
18 | @import "px-defaults-design/_settings.defaults.scss";
19 |
20 | // Generic
21 | @import "px-normalize-design/_generic.normalize.scss";
22 | @import "px-box-sizing-design/_generic.box-sizing.scss";
23 |
24 | // Base
25 | @import "px-headings-design/_base.headings.scss";
26 |
27 | // Component
28 | :host([collapsed]) .backdrop {
29 | position: fixed;
30 | left: 0;
31 | top: 0;
32 | width: 100%;
33 | height: 100%;
34 | background-color: rgba(0,0,0,0.65);
35 | opacity: 0;
36 | transition: opacity 200ms ease;
37 | z-index: -1;
38 | }
39 |
40 | :host([collapsed]) .backdrop[visible] {
41 | opacity: 1;
42 | }
43 |
44 | :host([collapsed]) px-context-browser-panel {
45 | position: relative;
46 | z-index: 2;
47 | }
48 |
49 | .column {
50 | display: block;
51 | position: absolute;
52 | left: 0;
53 | top: 0;
54 | width: 100%;
55 | height: 100%;
56 | overflow-y: hidden;
57 | }
58 |
59 | .column.active {
60 | overflow-y: auto;
61 | }
62 |
63 | .column.animating {
64 | overflow-y: hidden;
65 | }
66 |
67 | $item-height: 30px;
68 | $item-height-favorites: 60px;
69 |
70 | px-context-browser-columns {
71 | display: block;
72 | position: relative;
73 | overflow: hidden;
74 | min-height: $item-height;
75 | transition: min-height 350ms;
76 | padding-top: 1px;
77 | }
78 |
79 | :host([favorited-opened]) px-context-browser-columns {
80 | min-height: $item-height-favorites;
81 | }
82 |
83 | px-context-browser-columns[visible-count] {
84 | min-height: ($item-height*10) + 1px;
85 | }
86 | px-context-browser-columns[visible-count="1"] {
87 | min-height: $item-height + 1px;
88 | }
89 | px-context-browser-columns[visible-count="2"] {
90 | min-height: ($item-height*2) + 1px;
91 | }
92 | px-context-browser-columns[visible-count="3"] {
93 | min-height: ($item-height*3) + 1px;
94 | }
95 | px-context-browser-columns[visible-count="4"] {
96 | min-height: ($item-height*4) + 1px;
97 | }
98 | px-context-browser-columns[visible-count="5"] {
99 | min-height: ($item-height*5) + 1px;
100 | }
101 | px-context-browser-columns[visible-count="6"] {
102 | min-height: ($item-height*6) + 1px;
103 | }
104 | px-context-browser-columns[visible-count="7"] {
105 | min-height: ($item-height*7) + 1px;
106 | }
107 | px-context-browser-columns[visible-count="8"] {
108 | min-height: ($item-height*8) + 1px;
109 | }
110 | px-context-browser-columns[visible-count="9"] {
111 | min-height: ($item-height*9) + 1px;
112 | }
113 |
114 | :host([favorited-opened]) px-context-browser-columns[visible-count] {
115 | min-height: ($item-height-favorites*10) + 1px;
116 | }
117 |
118 | :host([favorited-opened]) px-context-browser-columns[visible-count="1"] {
119 | min-height: $item-height-favorites + 1px;
120 | }
121 | :host([favorited-opened]) px-context-browser-columns[visible-count="2"] {
122 | min-height: ($item-height-favorites*2) + 1px;
123 | }
124 | :host([favorited-opened]) px-context-browser-columns[visible-count="3"] {
125 | min-height: ($item-height-favorites*3) + 1px;
126 | }
127 | :host([favorited-opened]) px-context-browser-columns[visible-count="4"] {
128 | min-height: ($item-height-favorites*4) + 1px;
129 | }
130 | :host([favorited-opened]) px-context-browser-columns[visible-count="5"] {
131 | min-height: ($item-height-favorites*5) + 1px;
132 | }
133 | :host([favorited-opened]) px-context-browser-columns[visible-count="6"] {
134 | min-height: ($item-height-favorites*6) + 1px;
135 | }
136 | :host([favorited-opened]) px-context-browser-columns[visible-count="7"] {
137 | min-height: ($item-height-favorites*7) + 1px;
138 | }
139 | :host([favorited-opened]) px-context-browser-columns[visible-count="8"] {
140 | min-height: ($item-height-favorites*8) + 1px;
141 | }
142 | :host([favorited-opened]) px-context-browser-columns[visible-count="9"] {
143 | min-height: ($item-height-favorites*9) + 1px;
144 | }
145 |
146 | px-context-browser-columns[collapsed],
147 | px-context-browser-columns[collapsed][visible-count],
148 | px-context-browser-columns[collapsed][visible-count="*"] {
149 | min-height: auto;
150 | flex: 1 1 auto;
151 | }
152 |
153 | .context-browser-favorites--empty__container {
154 | display: flex;
155 | flex-direction: column;
156 | align-items: center;
157 | justify-content: center;
158 | max-width: 80%;
159 | margin-left: auto;
160 | margin-right: auto;
161 | height: calculateRem(340px);
162 | }
163 |
164 | .context-browser-favorites--empty__text {
165 | color: var(--px-context-browser-item-text-color, black);
166 | margin-bottom: calculateRem(10px);
167 | text-align: center;
168 | }
169 |
170 | .context-browser-favorites--empty__subtext {
171 | color: var(--px-context-browser-item-breadcrumbs-color, gray);
172 | line-height: calculateRem(12px);
173 | text-align: center;
174 | max-width: 100%;
175 | }
176 |
177 | .context-browser-favorites--empty__icon {
178 | margin-bottom: calculateRem(30px);
179 | --iron-icon-height: calculateRem(70px);
180 | --iron-icon-width: calculateRem(70px);
181 | --iron-icon-fill-color: var(--px-context-browser-empty-favorites-icon-color, whitesmoke);
182 | --iron-icon-stroke-color: var(--px-context-browser-empty-favorites-icon-stroke-color, lightgray);;
183 | stroke-width: calculateRem(0.5px);
184 | }
185 |
--------------------------------------------------------------------------------
/px-context-browser-columns.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
177 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Predix UI
Hi,
Want to contribute your suggestions to Predix UI? **Here's how you can help.**
Please follow the below steps carefully, so your suggestions will be clear and developers can make effective fixes.
## Using the GitHub issue tracker
The GitHub issue tracker is the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests)
and [submitting pull requests](#pull-requests), so please respect the following
restrictions:
* Please **do not** use the GitHub issue tracker for personal support requests. Stack
Overflow ([`predix ui`](https://stackoverflow.com/questions/tagged/predix-ui) tag), or [Predix.io](https://predix.io) are better places to get help.
* Please **do not** derail or troll issues. Keep the discussion on topic and
respect the opinions of others.
* Please **do not** post vague comments like "+1" or ":thumbsup:".
Use [GitHub's "reactions" feature](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). We reserve the right to delete comments.
## Issues and labels
Our bug tracker utilizes several labels to help organize and identify issues. Here's what they represent and how we use them:
- `browser bug` - Issues that are reported to us, but are actually the result of a browser-specific bug. These issues are diagnosed with reduced test cases and result in an issue opened on that browser's own bug tracker.
- `confirmed` - Issues that have been confirmed with a reduced test case and identify a bug in a Predix UI component.
- `css` - Issues stemming from our compiled CSS or source Sass files.
- `docs` - Issues for improving or updating our documentation.
- `examples` - Issues involving the example templates included in our docs.
- `enhancement` - Issues asking for a new feature to be added, or an existing one to be extended or modified. New features require a minor version bump (e.g., `v3.0.0` to `v3.1.0`).
- `grunt` - Issues with our included JavaScript-based Gruntfile, which is used to run all our tests, concatenate and compile source files, and more.
- `help wanted` - Issues that we need or would like the community to help us resolve.
- `js` - Issues stemming from our compiled or source JavaScript files.
- `meta` - Issues with the project itself or our GitHub repository.
## Bug reports
A bug is a _demonstrable problem_ caused by the code in the repository.
Good bug reports are extremely helpful.
Guidelines for bug reports:
0. **Validate and lint your code**; [validate your HTML](http://html5.validator.nu)
and [lint your HTML](http://www.dirtymarkup.com/) to ensure your
problem isn't caused by a simple error in your own code.
1. **Use the GitHub issue search**; check if the issue has already been
reported.
2. **Check if the issue has been fixed**; try to reproduce the issue by using the
latest `master` or development branch in the repository.
3. **Isolate the problem**; ideally create a [reduced test
case](https://css-tricks.com/reduced-test-cases/) and a live example using [CodePen](http://codepen.io/mdwragg/pen/LNwmpB) or [jsfiddle](https://jsfiddle.net/Lqmcwhw0/3/).
A good bug report shouldn't require others to get more information. Please be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What browser(s) and OS experience the problem? Do other browsers show the bug differently? What would you expect for the outcome? Such details will help people fix potential bugs.
Example:
> Short and descriptive example bug report title
>
> A summary of the issue and the browser/OS environment in which it occurs. If
> suitable, include the steps required to reproduce the bug.
>
> 1. This is the first step
> 2. This is the second step
> 3. Further steps, etc.
>
> `` - a link to the reduced test case
>
> Any other information relevant to the bug report. This might include the lines of code that you have identified as
> causing the bug, and potential solutions (and your opinions on their
> merits).
## Feature Requests
Feature requests are welcome, but before opening one, determine if your idea suits the scope and aims of Predix UI. *You* need to make a strong case and convince the Predix UI team to adopt your feature. Please provide as much detail and context as possible.
## Pull Requests
Your pull requests�patches, improvements, and new features�are a big help. The requests should be focused and avoid unrelated commits.
**Please ask** before making a significant pull request (e.g., implementing features, refactoring code, or porting to a different language) that Predix UI developers might not merge into the component.
Please follow the [coding guidelines](#code-guidelines) used throughout the project (indentation, accurate comments, etc.) and any other requirements (such as test coverage).
**Do not edit any of the CSS files directly!** The files are automatically generated. You should edit the source files in [`sass/`] instead.
**Do not edit the `gh-pages` branch.** That branch is generated from the documentation source files and is managed separately by the Predix UI team.
Please use the following process to have your work considered for the project:
1. [Fork](https://help.github.com/fork-a-repo/) the component.
2. Create a new topic branch (off the main project development branch) to
contain your feature, change, or fix:
```
bash
git checkout -b
```
3. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) or your code is unlikely to be merged into the main project. Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public.
4. Locally merge (or rebase) the latest commits into your branch:
```
bash
git pull [--rebase] origin master
```
5. Push your topic branch up to your fork:
```
bash
git push origin
```
6. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description against the `master` branch.
## Code guidelines
### HTML
[Adhere to the Code Guide.](http://codeguide.co/#html)
- Use tags and elements appropriate for an HTML5 doctype (e.g., self-closing tags).
- Use [WAI-ARIA](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) attributes in documentation examples to promote accessibility.
### CSS
[Adhere to the Code Guide.](http://codeguide.co/#css)
- When feasible, default color palettes should comply with [WCAG color contrast guidelines](http://www.w3.org/TR/WCAG20/#visual-audio-contrast).
- Except in rare cases, don't remove default `:focus` styles (via e.g. `outline: none;`) without providing alternative styles. See [this A11Y Project post](http://a11yproject.com/posts/never-remove-css-outlines/) for more details.
### JS
- 2 spaces (no tabs)
- "Attractive"
- no errors / warnings
--------------------------------------------------------------------------------
/css/px-context-browser-filter-styles.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
22 |
23 |
--------------------------------------------------------------------------------
/examples/favorites-app.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 | Favorite Foods app
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
95 |
96 |
97 |
98 |
102 |
103 |
104 |
105 |
106 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
256 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/HISTORY.md:
--------------------------------------------------------------------------------
1 | v2.2.0
2 | ==================
3 | * Set `showFavorited` default value to false. The developer should set the
4 | `show-favorited` attribute on the context browser element to enable favoriting
5 |
6 | v2.1.7
7 | ==================
8 | * Replace px-context-browser-contextual-notification with px-notification
9 |
10 | v2.1.6
11 | ==================
12 | * reduce icon-set imports
13 |
14 | v2.1.5
15 | ==================
16 | * fixing demo pages for IE11
17 |
18 | v2.1.4
19 | ==================
20 | * Add support for localization
21 |
22 | v2.1.3
23 | ==================
24 | * Fix truncation for items and header in ie11
25 |
26 | v2.1.2
27 | ==================
28 | * Demo fix: Remove dead demo code for trigger
29 |
30 | v2.1.1
31 | ==================
32 | * Demo fix: ensure template has rendered before querying it
33 |
34 | v2.1.0
35 | ==================
36 | * Add Polymer 1.x/2.x hybrid element support
37 | * Add favoriting feature to allow users to 'favorite' items in the context
38 | browser and see those items listed in a separate Favorited Items Panel
39 |
40 | v2.0.14
41 | ==================
42 | * add device flags
43 |
44 | v2.0.13
45 | ==================
46 | * cut over to px-icon-set for actions
47 |
48 | v2.0.12
49 | ==================
50 | * Adds `isSelectable` configuration for items
51 |
52 | v2.0.11
53 | ==================
54 | * Fix label color bug (#89)
55 |
56 | v2.0.10
57 | ==================
58 | * change default behavior to close on-select, add keep-open property to prevent (#86)
59 |
60 | v2.0.9
61 | ==================
62 | * fix documentation
63 |
64 | v2.0.8
65 | ==================
66 | * fix documentation
67 |
68 | v2.0.7
69 | ==================
70 | * fix documentation
71 |
72 | v2.0.6
73 | ==================
74 | * Fixes support for custom keys (id, children, label) and adds support
75 | for changing keys at runtime
76 |
77 | v2.0.5
78 | ==================
79 | * Fix to support runtime re-assignment of `items`
80 |
81 | v2.0.4
82 | ==================
83 | * Fix comment for analyzer
84 |
85 | v2.0.3
86 | ==================
87 | * Fix bug so that filter icon shows up in IE
88 |
89 | v2.0.2
90 | ==================
91 | * Fix bugs in demo
92 |
93 | v2.0.1
94 | ==================
95 | * Fix dark theme
96 |
97 | v2.0.0
98 | ==================
99 | * Complete rebuild of the context browser with all new APIs. See the
100 | documentation for more information on the new APIs and how to migrate your
101 | existing code.
102 | * New, refreshed design. The browser is now a single column panel that opens
103 | when its trigger is tapped.
104 | * Re-architected to work side-by-side with other Predix Design System components
105 | used to navigate assets/context (px-tree, px-breadcrumbs).
106 | * The `` tag no longer places a button
107 | on the page. Use the px-context-browser tag together with a `` tag show a button
108 | that opens the browser. See the documentation for more information on binding
109 | these two elements together.
110 | * The `browserContext` property has been renamed to `items`. The structure of
111 | the context browser items has been completely overhauled.
112 | * The `browserContext` property `name` has been replaced with `label`.
113 | * The `browserContext` property `identifier` has been replaced with `id`.
114 | * The `browserContext` property `isOpenable` has been removed.
115 | * The initial context and direct context modes have been removed. Set the
116 | `selected` property instead to select an item after loading the data.
117 | * The `disabled` property has been removed.
118 | * The `disableInfiniteScroll` property has been removed.
119 | * The `handlers` property has been removed. Listen to the event
120 | `px-app-asset-children-requested` to be notified when new children should be
121 | loaded. Listen to the event `selected-changed` to be notified when an item is
122 | selected (tapped or selected through data binding). See the documentation for
123 | more info. There is no event fired when an item is tapped but not selected as
124 | that interaction pattern has been removed.
125 | * The `idField` and `labelField` properties have been removed. Use the `keys`
126 | property to set both instead.
127 | * The `openedItemName` property has been removed. Listen to the event
128 | `selected-changed` to be notified when a new item is selected.
129 | * The `resize` property has been removed.
130 | * The `selectedItem` property has been renamed to `selected`. Its behaviors are
131 | also slightly different, see the documentation.
132 | * The `showChevron` property has been renamed to `showArrow`.
133 | * The `showColumnBrowser` property has been removed.
134 | * The `showColumnTypeahead` property has been removed. Use the `showFilter`
135 | property to show a filter field at the top of the column.
136 | * The `addParents` method has been removed. Instead, add items from the root of
137 | the graph using `addChildren`.
138 | * The `toggleColumnBrowser` method has been removed. Toggle the `collapsed`
139 | property to show or hide the context browser.
140 | * The events have changed completely. See the documentation for more details.
141 |
142 | v1.8.0
143 | ==================
144 | * added localization for 'Open'
145 |
146 | v1.7.0
147 | ==================
148 | * added a disableInfiniteScroll property to... disable infinite scrolling, which happens automatically on scroll.
149 |
150 | v1.6.11
151 | ==================
152 | * merge PR #39 - Add an onRejected promise handler for to getChildren
153 |
154 | v1.6.10
155 | ==================
156 | * fix #37 regarding labels in breadcrumb
157 |
158 | v1.6.9
159 | ==================
160 | * merge PR #36 - allow selectedAsset to have children.
161 |
162 | v1.6.8
163 | ==================
164 | * merge PR #35
165 |
166 | v1.6.7
167 | ==================
168 | * fix unit tests for typeahead
169 |
170 | v1.6.6
171 | ==================
172 | * changed 'search' to 'filter' in typeahead
173 |
174 | v1.6.5
175 | ==================
176 | * fixed memory leak, causing using setinterval.
177 | * re-wrote some functions for readability
178 | * added lots of documentation.
179 |
180 | v1.6.4
181 | ==================
182 | * increased context browser from 2 to 5
183 | * created css variable --px-cb-background-z-index
184 | * created css variable --px-cb-spinner-z-index
185 |
186 | v1.6.3
187 | ==================
188 | * put in cloudflare cache cleaner
189 |
190 | v1.6.2
191 | ==================
192 | * put in new demo
193 |
194 | v1.6.1
195 | ==================
196 | * Update colors design to pick up new colors
197 |
198 | v1.6.0
199 | ==================
200 | * merge PR #32, allow CB to be disabled
201 |
202 | v1.5.3
203 | ==================
204 | * merge PR that fixed typeahead bug
205 |
206 | v1.5.2
207 | ==================
208 | * changing ghp.sh to account for Alpha releases
209 |
210 | v1.5.1
211 | ==================
212 | * fixed win8.1 ie11 test bug.
213 |
214 | v1.5.0
215 | ==================
216 | * add search per column (filter) capability
217 |
218 | v1.4.5
219 | ==================
220 | * fixed bug that removed the scrollbars
221 |
222 | v1.4.4
223 | ==================
224 | * rebuild sass for headings design update
225 |
226 | v1.4.3
227 | ==================
228 | * added an extra visuallyhidden class to ensure the selected context browser item doesn't show up when open is clicked.
229 |
230 | v1.4.2
231 | ==================
232 | * removed content-wrapper__item class
233 |
234 | v1.4.1
235 | ==================
236 | * Update missed design depndencies
237 |
238 | v1.4.0
239 | ==================
240 | * Updated dependencies
241 |
242 | v1.3.17
243 | ==================
244 | * changing browser in wct testing from safari 8 to safari 10 on elcapitan
245 |
246 | v1.3.16
247 | ==================
248 | * updating slider dependency
249 |
250 | v1.3.15
251 | ==================
252 | * changing all devDeps to ^
253 |
254 | v1.3.14
255 | ==================
256 | * Update px-theme to 2.0.1 and update test fixtures
257 |
258 | v1.3.13
259 | ==================
260 | * update dependencies for dropdown
261 |
262 | v1.3.12
263 | ==================
264 | * changed i to iron-icon
265 |
266 | v1.3.11
267 | ==================
268 | * removing px-theme style call
269 |
270 | v1.3.10
271 | ==================
272 | * changed css variables to be consistent with BEM
273 |
274 | v1.3.9
275 | ==================
276 | * bower updating px-demo-snippet
277 |
278 | v1.3.8
279 | ====================
280 | * added style variables for theming
281 |
282 | v1.3.7
283 | ====================
284 | * updated the header so it's always vertically centered.
285 |
286 | v1.3.6
287 | ====================
288 | * Update dependencies
289 |
290 | v1.3.3
291 | ====================
292 | * Add some top to make sure expanded 'ruler' is correctly positioned.
293 |
294 | v1.3.2
295 | ====================
296 | * Revert position change introduced in v1.0.7. Was causing issues in seed app by pushing content down the page.
297 |
298 | v1.3.1
299 | ====================
300 | * Fix dropdown icon size. CSS shadow dom fixes and load order of sass partials.
301 |
302 | v1.3.0
303 | ====================
304 | * Grunt to gulp conversion and move to style modues.
305 |
306 | v1.2.0
307 | ====================
308 | * Add content tag to allow insertion of deck selector.
309 |
310 | v1.1.0
311 | ====================
312 | * migrate styles to style module
313 |
314 | v1.0.10
315 | ====================
316 | * fixed demo bugs
317 |
318 | v1.0.9
319 | ====================
320 | * brought the Q library back in for local dev.
321 |
322 | v1.0.8
323 | ====================
324 | * updated mega demo styles and bower px-demo-snippet to ^
325 |
326 | v1.0.7
327 | ====================
328 | * Chrome changed its behavior from version 51 to 52, and was causing the header to be hidden behind the absolutely positioned browser. I changed the positioning to relative. also switched the old font awesome to one that works in shadow dom.
329 |
330 | v1.0.6
331 | ====================
332 | * PR that changed how the breadcrumbs are rebuilt, allowing items with children not in the selected path
333 | v1.0.5
334 | ====================
335 | * removed the old demo vulcanize from the auto build script
336 |
337 | v1.0.4
338 | ====================
339 | * added image to readme, removed watch, added view on github
340 |
341 | v1.0.3
342 | ====================
343 | * updated gh-pages script to vulcanize demo
344 |
345 | v1.0.2
346 | ====================
347 | * Add import and config of px-iconography-design (again)
348 | * Add import and config of px-typography-design (again)
349 | * removed importQ.html from ignore
350 |
351 | v1.0.1
352 | ====================
353 | * added new demo
354 |
355 | v1.0.0
356 | ====================
357 | * Add import and config of px-iconography-design
358 | * Add import and config of px-typography-design
359 |
360 | v0.10.0
361 | ====================
362 | * Upgrade to Polymer 1.5.0
363 |
364 | v0.9.7
365 | ====================
366 | * Merged PR which fixed lazy loading spinner bug
367 |
368 | v0.9.5
369 | ====================
370 | * removed unnecessary check on breadcrumbs
371 |
372 | v0.9.5
373 | ====================
374 | * added oss_notice to bower ignore
375 |
376 | v0.9.4
377 | ====================
378 | * added pull request test
379 |
380 | v0.9.3
381 | ====================
382 | * added auto github pages functionality
383 |
384 | v0.9.2
385 | ====================
386 | * fixed tests
387 |
388 | v0.9.1
389 | ====================
390 | * fixed the breadcrumbs so they adhere to specs
391 |
392 | v0.9.0
393 | ====================
394 | * Upgrade to Polymer 1.4.0
395 |
396 | v0.8.6
397 | ====================
398 | * cleaned up docs a bit, and cleaned up css class methods.
399 |
400 | v0.8.5
401 | ====================
402 | * Updated travis file
403 |
404 | v0.8.4
405 | ====================
406 | * Updated documentation for api only.
407 |
408 | v0.8.3
409 | ====================
410 | * updated the link for Github Issues
411 |
412 | v0.8.2
413 | ====================
414 | * changed line height for selected items to help differentiate them from non-selected items
415 |
416 | v0.8.1
417 | ====================
418 | * Updated License
419 |
420 | v0.8.0
421 | ====================
422 | * Removed the default reference to the item chevron, since the Predix asset team does not support that. the functionality is still there, but now, you have to pass an attribute (has-children) and set it to true to ensure the chevrons show up.
423 |
--------------------------------------------------------------------------------
/test/px-context-browser-tests.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | * Copyright (c) 2018, General Electric
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | const convertNodeListToArray = (l) => Array.isArray(l) ? l : Array.prototype.slice.call(l || []);
19 |
20 | describe('px-context-browser', function() {
21 | it('opens when the trigger is tapped', function(done) {
22 | var fx = fixture('ContextBrowser');
23 |
24 | flush(() => {
25 | var triggerEl = fx.querySelector('px-context-browser-trigger');
26 | var browserEl = fx.querySelector('px-context-browser');
27 |
28 | browserEl.items = [{ id: 'home', label: 'Home' }];
29 | browserEl.openTrigger = triggerEl.trigger;
30 |
31 | triggerEl.click();
32 |
33 | setTimeout(function() {
34 | expect(browserEl.opened).to.equal(true);
35 | done();
36 | }, 250);
37 | });
38 | });
39 |
40 | it('resets its active item to the parent of the selected item 5s after it is closed', function(done) {
41 | var fx = fixture('ContextBrowserBindingFixture');
42 |
43 | flush(() => {
44 | var triggerEl = fx.querySelector('px-context-browser-trigger');
45 | var browserEl = fx.querySelector('px-context-browser');
46 |
47 | browserEl.openTrigger = triggerEl;
48 | browserEl.items = [
49 | { id: "home", label: "Home" },
50 | { id: "asset", label: "Assets", children: [
51 | { id: "a1", label: "Asset 1" },
52 | { id: "a2", label: "Asset 2" }
53 | ] }
54 | ];
55 | triggerEl.click();
56 |
57 | setTimeout(function() {
58 | browserEl.selectedRoute = ['asset', 'a1'];
59 | }, 250);
60 | setTimeout(function() {
61 | browserEl.active = null;
62 | document.body.click();
63 | }, 500);
64 | setTimeout(function() {
65 | triggerEl.click();
66 | }, 6500);
67 | setTimeout(function() {
68 | expect(browserEl.active).to.equal(browserEl.items[1]);
69 | done();
70 | }, (6500 + 250));
71 | });
72 | });
73 |
74 | it('resets its active item to the parent of the selected item 5s after it is closed when `opened` is data-bound in', function(done) {
75 | var fx = fixture('ContextBrowserBindingFixture');
76 |
77 | flush(() => {
78 | var triggerEl = fx.querySelector('px-context-browser-trigger');
79 | var browserEl = fx.querySelector('px-context-browser');
80 |
81 | browserEl.openTrigger = triggerEl;
82 | browserEl.items = [
83 | { id: "home", label: "Home" },
84 | { id: "asset", label: "Assets", children: [
85 | { id: "a1", label: "Asset 1" },
86 | { id: "a2", label: "Asset 2" }
87 | ] }
88 | ];
89 |
90 | browserEl.opened = false;
91 | triggerEl.click();
92 |
93 | setTimeout(function() {
94 | browserEl.selectedRoute = ['asset', 'a1'];
95 | }, 250);
96 | setTimeout(function() {
97 | browserEl.active = null;
98 | document.body.click();
99 | }, 500);
100 | setTimeout(function() {
101 | triggerEl.click();
102 | }, 6500);
103 | setTimeout(function() {
104 | expect(browserEl.active).to.equal(browserEl.items[1]);
105 | done();
106 | }, (6500 + 250));
107 | });
108 | });
109 |
110 | // it('does not reset its active item if it is reopened after less than 5s', function(done) {
111 | // var fx = fixture('ContextBrowserBindingFixture');
112 | // var boundEl = fx.querySelector('#app');
113 | // var triggerEl = fx.querySelector('px-context-browser-trigger');
114 | // var browserEl = fx.querySelector('px-context-browser');
115 | //
116 | // boundEl.items = [
117 | // { id: "home", label: "Home" },
118 | // { id: "asset", label: "Assets", children: [
119 | // { id: "a1", label: "Asset 1" },
120 | // { id: "a2", label: "Asset 2" }
121 | // ] }
122 | // ];
123 | //
124 | // triggerEl.click();
125 | //
126 | // setTimeout(function() {
127 | // browserEl.selectedRoute = ['asset', 'a1'];
128 | // }, 250);
129 | // setTimeout(function() {
130 | // browserEl.active = null;
131 | // document.body.click();
132 | // }, 500);
133 | // setTimeout(function() {
134 | // triggerEl.click();
135 | // }, 1000);
136 | // setTimeout(function() {
137 | // expect(browserEl.active).to.equal(null);
138 | // done();
139 | // }, (1000 + 250));
140 | // });
141 | //
142 | // it('does not reset its active item if it is reopened after less than 5s when `opened` is data-bound in', function(done) {
143 | // var fx = fixture('ContextBrowserBindingFixture');
144 | // var boundEl = fx.querySelector('#app');
145 | // var triggerEl = fx.querySelector('px-context-browser-trigger');
146 | // var browserEl = fx.querySelector('px-context-browser');
147 | //
148 | // boundEl.items = [
149 | // { id: "home", label: "Home" },
150 | // { id: "asset", label: "Assets", children: [
151 | // { id: "a1", label: "Asset 1" },
152 | // { id: "a2", label: "Asset 2" }
153 | // ] }
154 | // ];
155 | //
156 | // boundEl.opened = false;
157 | // triggerEl.click();
158 | //
159 | // setTimeout(function() {
160 | // browserEl.selectedRoute = ['asset', 'a1'];
161 | // }, 250);
162 | // setTimeout(function() {
163 | // browserEl.active = null;
164 | // document.body.click();
165 | // }, 500);
166 | // setTimeout(function() {
167 | // triggerEl.click();
168 | // }, 2000);
169 | // setTimeout(function() {
170 | // expect(browserEl.active).to.equal(null);
171 | // done();
172 | // }, (2000 + 250));
173 | // });
174 |
175 | });
176 |
177 | describe('px-context-browser [favorited behaviors]', () => {
178 | let fx;
179 | let items;
180 | let openTrigger;
181 | let favoritedTrigger;
182 | let browser;
183 |
184 | beforeEach(done => {
185 | fx = fixture('ContextBrowserFavoritedFixture');
186 | flush(() => {
187 | browser = fx.querySelector('px-context-browser');
188 | openTrigger = fx.querySelector('#openTrigger');
189 | favoritedTrigger = fx.querySelector('#favoritedTrigger');
190 | browser.openTrigger = openTrigger;
191 | browser.favoritedTrigger = favoritedTrigger;
192 | items = [
193 | { id: "home", label: "Home" },
194 | { id: "asset", label: "Assets", children: [
195 | { id: "a1", label: "Asset 1" },
196 | { id: "a2", label: "The Second Asset", children: [
197 | { id: "abc", label: "ABC" },
198 | { id: "long", label: "My Very Long Child Asset", children: [
199 | { id: "fave", label: "My Favorite Asset" }
200 | ]}
201 | ]}
202 | ]}
203 | ];
204 | browser.items = items;
205 | done();
206 | });
207 | });
208 |
209 | it('opens the favorited panel when the favorited trigger is tapped', (done) => {
210 | favoritedTrigger.click();
211 | flush(() => {
212 | expect(browser.favoritedOpened).to.be.true;
213 | done();
214 | });
215 | });
216 |
217 | it('opens the favorited panel to an empty view if there are no currently favorited items', (done) => {
218 | favoritedTrigger.click();
219 | flushAndRender(() => {
220 | const emptyText = Polymer.dom(browser.root).querySelector('.context-browser-favorites--empty__text');
221 | const emptyTextRect = emptyText.getBoundingClientRect();
222 | expect(emptyTextRect.left > 0).to.be.true;
223 | expect(emptyTextRect.height).to.be.closeTo(19, 5);
224 | done();
225 | }, 10);
226 | });
227 |
228 | it('opens the favorited panel to a list view if there are favorited items', (done) => {
229 | browser.favorited = [items[0], items[1]];
230 | favoritedTrigger.click();
231 | flush(() => {
232 | const itemEls = Polymer.dom(browser.root).querySelectorAll('px-context-browser-item');
233 | const favoritedItem = convertNodeListToArray(itemEls).filter(item => item.styleAsFavorite && item.label === 'Home')[0];
234 | favoritedItemRect = favoritedItem.getBoundingClientRect();
235 | expect(favoritedItemRect.left > 0).to.be.true;
236 | expect(favoritedItemRect.height).to.be.closeTo(60, 5);
237 | done();
238 | });
239 | });
240 |
241 | it('immediately adds an item to `favorited` when the user taps the favorite icon in the regular browser', (done) => {
242 | openTrigger.click();
243 | flush(() => {
244 | expect(browser.favorited.length === 0).to.be.true;
245 | const itemEls = Polymer.dom(browser.root).querySelectorAll('px-context-browser-item');
246 | const homeItem = convertNodeListToArray(itemEls).filter(item => !item.styleAsFavorite && item.label === 'Home')[0];
247 | const favIcon = Polymer.dom(homeItem.root).querySelector('px-context-browser-action-favorite');
248 | MockInteractions.tap(favIcon);
249 | flush(() => {
250 | expect(browser.favorited.indexOf(items[0]) > -1).to.be.true;
251 | done();
252 | });
253 | });
254 | });
255 |
256 | it('immediately removes a currently favorited item from `favorited` when the user taps the favorite icon in the regular browser', (done) => {
257 | browser.favorited = [items[0], items[1]];
258 | openTrigger.click();
259 | flush(() => {
260 | const itemEls = Polymer.dom(browser.root).querySelectorAll('px-context-browser-item');
261 | const homeItem = convertNodeListToArray(itemEls).filter(item => !item.styleAsFavorite && item.label === 'Home')[0];
262 | const favIcon = Polymer.dom(homeItem.root).querySelector('px-context-browser-action-favorite');
263 | // Must use the MockInteractions tap event here to ensure test triggers listeners
264 | // in Polymer 2.x with shadow DOM
265 | MockInteractions.tap(favIcon);
266 | expect(browser.favorited.indexOf(items[0]) === -1).to.be.true;
267 | done();
268 | });
269 | });
270 |
271 | it('marks an item as defavorited but keeps it in the favorites list when the user taps the favorite icon in the favorites browser', (done) => {
272 | browser.favorited = [items[0],items[1]];
273 | favoritedTrigger.click();
274 | flush(() => {
275 | const itemEls = Polymer.dom(browser.root).querySelectorAll('px-context-browser-item');
276 | const homeItem = convertNodeListToArray(itemEls).filter(item => item.styleAsFavorite && item.label === 'Home')[0];
277 | const favIcon = Polymer.dom(homeItem.root).querySelector('px-context-browser-action-favorite');
278 | MockInteractions.tap(favIcon);
279 | flush(() => {
280 | expect(browser.favorited.indexOf(items[0]) > -1).to.be.true;
281 | expect(favIcon.hasAttribute('active')).to.be.false;
282 | done();
283 | });
284 | });
285 | });
286 |
287 | it('updates favorited when the favorites browser is closed for > 5 seconds and the state is dirty', (done) => {
288 | browser.favorited = [items[0], items[1]];
289 | favoritedTrigger.click();
290 | flush(() => {
291 | const itemEls = Polymer.dom(browser.root).querySelectorAll('px-context-browser-item');
292 | const homeItem = convertNodeListToArray(itemEls).filter(item => item.styleAsFavorite && item.label === 'Home')[0];
293 | const favIcon = Polymer.dom(homeItem.root).querySelector('px-context-browser-action-favorite');
294 | MockInteractions.tap(favIcon);
295 | favoritedTrigger.click();
296 | // wait at least 5 seconds
297 | expect(() => browser.favorited.indexOf(items[0]) === -1)
298 | .to.eventuallyEqual(true, {within: 9000, every: 250}, done);
299 | });
300 | });
301 |
302 | it('updates favorited when the user opens the regular browser and the state is dirty', (done) => {
303 | browser.favorited = [items[0], items[1]];
304 | favoritedTrigger.click();
305 | flush(() => {
306 | const itemEls = Polymer.dom(browser.root).querySelectorAll('px-context-browser-item');
307 | const homeItem = convertNodeListToArray(itemEls).filter(item => item.styleAsFavorite && item.label === 'Home')[0];
308 | const favIcon = Polymer.dom(homeItem.root).querySelector('px-context-browser-action-favorite');
309 | MockInteractions.tap(favIcon);
310 | openTrigger.click();
311 | // wait at least 5 seconds
312 | expect(() => browser.favorited.indexOf(items[0]) === -1)
313 | .to.eventuallyEqual(true, {within: 9000, every: 250}, done);
314 | });
315 | });
316 |
317 | it('shows breadcrumbs for non-root items in the Favorites Panel', (done) => {
318 | browser.favorited = [items[1].children[1].children[0]];
319 | favoritedTrigger.click();
320 | flushAndRender(() => {
321 | const itemEls = Polymer.dom(browser.root).querySelectorAll('px-context-browser-item');
322 | const favoriteItem = convertNodeListToArray(itemEls).filter(item => item.styleAsFavorite && item.label === 'ABC')[0];
323 | const itemBreadcrumbs = Polymer.dom(favoriteItem.root).querySelector('#breadcrumbs');
324 | expect(itemBreadcrumbs.innerText.trim()).to.equal("Assets > The Second Asset");
325 | done();
326 | }, 10);
327 | });
328 |
329 | it('truncates breadcrumbs text from the front if too long', (done) => {
330 | browser.favorited = [items[1].children[1].children[1].children[0]];
331 | favoritedTrigger.click();
332 | flushAndRender(() => {
333 | const itemEls = Polymer.dom(browser.root).querySelectorAll('px-context-browser-item');
334 | const favoriteItem = convertNodeListToArray(itemEls).filter(item => item.styleAsFavorite && item.label === 'My Favorite Asset')[0];
335 | const itemBreadcrumbs = Polymer.dom(favoriteItem.root).querySelector('#breadcrumbs');
336 | expect(itemBreadcrumbs.innerText.trim()).to.equal("... > The Second Asset > My Very Long Child Asset");
337 | done();
338 | }, 10);
339 | });
340 |
341 | it('breadcrumbs truncation algorithm works as expected', (done) => {
342 | const items = ['US', 'CA', 'Oakland'];
343 | const oneItem = ['Oakland'];
344 | const fontStyles = {size: "15px", family: "\"GE Inspira Sans\", sans-serif"};
345 | favoritedTrigger.click();
346 | flush(() => {
347 | const itemEl = Polymer.dom(browser.root).querySelector('px-context-browser-item');
348 | expect(itemEl._truncateBreadcrumbs(items, fontStyles, 120)).to.equal('US > CA > Oakland'); // width = 117
349 | expect(itemEl._truncateBreadcrumbs(items, fontStyles, 110)).to.equal('... > CA > Oakland'); // width = 108
350 | expect(itemEl._truncateBreadcrumbs(items, fontStyles, 100)).to.equal('... > Oakland'); // width = 76
351 | expect(itemEl._truncateBreadcrumbs(items, fontStyles, 70)).to.equal('... > Oakland'); // end truncation will happen through CSS
352 | expect(itemEl._truncateBreadcrumbs(oneItem, fontStyles, 60)).to.equal('Oakland'); // width = 52
353 | expect(itemEl._truncateBreadcrumbs(oneItem, fontStyles, 50)).to.equal('Oakland'); // end truncation will happen through CSS
354 | done();
355 | });
356 | });
357 |
358 | it('shows a contextual notification in the favorites panel but not the regular context browser if `favoritedSyncFailed` is true', (done) => {
359 | browser.favoritedSyncFailed = true;
360 | favoritedTrigger.click();
361 | setTimeout(() => {
362 | const contextualNotification = Polymer.dom(browser.root).querySelector('px-context-browser-contextual-notification');
363 | let contextualNotificationRect = contextualNotification.getBoundingClientRect();
364 | expect(contextualNotificationRect.left > 0).to.be.true;
365 | expect(contextualNotificationRect.height).to.be.closeTo(80, 5);
366 | openTrigger.click();
367 |
368 | flushAndRender(() => {
369 | contextualNotificationRect = contextualNotification.getBoundingClientRect();
370 | expect(contextualNotificationRect.left).to.equal(0);
371 | expect(contextualNotificationRect.height).to.equal(0);
372 | done();
373 | }, 10);
374 | }, 1000);
375 | });
376 |
377 | it('fires the `px-app-asset-favorited-sync-requested` event when the contextual notification resync button is tapped', (done) => {
378 | var eventSpy = sinon.spy();
379 | browser.addEventListener('px-app-asset-favorited-sync-requested', eventSpy);
380 |
381 | browser.favoritedSyncFailed = true;
382 | favoritedTrigger.click();
383 | setTimeout(() => {
384 | const contextualNotification = Polymer.dom(browser.root).querySelector('px-context-browser-contextual-notification');
385 | const notification = Polymer.dom(contextualNotification.root).querySelector('px-notification');
386 | const resyncIcon = Polymer.dom(notification.root).querySelector('.notification-right px-icon');
387 | console.log(resyncIcon);
388 |
389 | MockInteractions.tap(resyncIcon);
390 | // resyncIcon.click();
391 | expect(eventSpy).to.have.been.calledOnce;
392 | done();
393 | }, 600);
394 | });
395 |
396 | it('updates the panel height to show the correct number of items in the Favorites Panel when new items are favorited', (done) => {
397 | browser.favorited = [items[0], items[1]];
398 | favoritedTrigger.click();
399 |
400 | setTimeout(() => {
401 | const panel = Polymer.dom(browser.root).querySelector('#favoritedPanel');
402 | let panelRect = panel.getBoundingClientRect();
403 | expect(panelRect.left).to.be.greaterThan(0);
404 | expect(panelRect.height).to.be.closeTo(140, 5);
405 |
406 | browser.favorite(items[1].children[0]);
407 | setTimeout(() => {
408 | let panelRect = panel.getBoundingClientRect();
409 | expect(panelRect.left).to.be.greaterThan(0);
410 | expect(panelRect.height).to.be.closeTo(200, 5);
411 | done();
412 | }, 2000);
413 | }, 2000);
414 | });
415 |
416 | it('updates the panel height to show the correct number of items in the Favorites Panel when items are filtered', (done) => {
417 | browser.favorited = [items[0], items[1], items[1].children[0]];
418 | browser.showFilter = true;
419 | favoritedTrigger.click();
420 |
421 | setTimeout(() => {
422 | const panel = Polymer.dom(browser.root).querySelector('#favoritedPanel');
423 | let panelRect = panel.getBoundingClientRect();
424 | expect(panelRect.left).to.be.greaterThan(0);
425 | expect(panelRect.height).to.be.closeTo(252, 5);
426 |
427 | browser.favoritedFilter = "h";
428 | setTimeout(() => {
429 | let panelRect = panel.getBoundingClientRect();
430 | expect(panelRect.left).to.be.greaterThan(0);
431 | expect(panelRect.height).to.be.closeTo(132, 5);
432 | done();
433 | }, 2000);
434 | }, 2000);
435 | });
436 |
437 | });
438 |
--------------------------------------------------------------------------------