Skip to content

Moving to a more stable way of compiling the styles #333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a4268fc
feat(namespacing): updated architecture to better facilitate namespacing
webark Mar 15, 2018
5bf2bab
fix: using local rather then imported so access the actual variable
webark Sep 19, 2018
69082eb
fix: sometimes `.trees['app']` is a string, and sometimes a node.
webark Sep 19, 2018
ea728d7
fix(template only components): checking the templates only feature co…
webark Dec 11, 2018
8243c31
chore(upgrade): upgraded ember and packages to latset version
webark Mar 20, 2019
55a07d4
refactor(deprication): updated to handle the ember routeing service
webark Mar 20, 2019
9521d31
chore(upgrade): updated yarn.lock to latest versions
webark Mar 23, 2019
cb50b87
refactor(babel plugin): moving away from augmenting individuals js files
webark May 22, 2019
2bb7745
chore(upgrade): upgraded to latest packages
webark May 22, 2019
4383926
fix(nested routes): handledling nested route style names appropriatly
webark May 22, 2019
09832f2
chore(upgrade): upgraded packages to the latest version
webark May 22, 2019
78c2810
refactor(route processing): the utility should not need to hanlde th…
webark May 23, 2019
c53d947
refactor(route processing): switched to useing the public 'parent' of…
webark May 23, 2019
426bf01
refactor: cleanup and and refactored some of the walker and compiling…
webark Jun 24, 2019
f8adb27
test: skipping tests for now to be picked up later
webark Jun 24, 2019
119e4bb
chore: upgardded all packages
webark Jun 24, 2019
1ac8dcf
refactor: split up into sequential preprocessors with each doing it's…
webark Jun 24, 2019
6ca9680
refactor: upgraded to latest pagakcges and now using new broccoli-fil…
webark Sep 9, 2019
dfd1a73
chore(cleanup): reomoving some files that where missed in the rebase
webark Sep 21, 2019
2f6424b
refactor(cleanup): cleaned up some old packages that hwere no longer …
webark Sep 21, 2019
ec62fb2
test(update): updating tests to work with latest after rebase
webark Sep 21, 2019
56ded89
chore(upgrade): upgraded to latest packages
webark Sep 21, 2019
269e84f
chore(node version): needs at least a node version of 10
webark Sep 21, 2019
0f19eea
test(version compbatibitiy): pushing to what it is now, can reign bac…
webark Sep 21, 2019
6465fde
test(travis): adding in a extra scenario cause travis doesn't like it…
webark Sep 21, 2019
4962649
test(travis config): had syntax error that was leading to an empty build
webark Sep 21, 2019
712686c
chore(upgrade packages): upgraded packages to latest versions
webark Dec 27, 2019
6331feb
refactor(overhaul): complete overhaul over all aspects and upgrades t…
webark Jul 11, 2020
c7137cc
feat(style-namepace): switched to using a helper for the raw 'style-n…
webark Jul 12, 2020
49b6fd3
feat(style registry): registering style types based off of style file…
webark Jul 23, 2020
a87dd7f
feat(co location): added tests and modifications for co location
webark Jul 23, 2020
c185043
feat(namespace modifier): moving to an element modifer rather then a …
webark Jul 23, 2020
64c0ae8
fix(lint): removed an extraneous semi colon
webark Jul 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .bowerrc

This file was deleted.

1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

root = true


[*]
end_of_line = lf
charset = utf-8
Expand Down
1 change: 0 additions & 1 deletion .ember-cli
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"usePods": true,
/**
Ember CLI sends analytics information by default. The data is completely
anonymous, but there are times when you might want to disable this behavior.
Expand Down
21 changes: 12 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
'use strict';

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
},
plugins: [
'ember'
Expand All @@ -14,12 +20,12 @@ module.exports = {
env: {
browser: true
},
rules: {
},
rules: {},
overrides: [
// node files
{
files: [
'lib/**/*.js',
'.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
Expand All @@ -36,17 +42,14 @@ module.exports = {
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
sourceType: 'script'
},
env: {
browser: false,
node: true
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
extends: ['plugin:node/recommended']
}
]
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/node_modules/

# misc
/.env*
/.pnp*
/.sass-cache
/connect.lock
/coverage/
Expand Down
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
/.bowerrc
/.editorconfig
/.ember-cli
/.env*
/.eslintignore
/.eslintrc.js
/.git/
/.gitignore
/.template-lintrc.js
/.travis.yml
Expand Down
2 changes: 1 addition & 1 deletion .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = {
extends: 'recommended'
extends: 'octane'
};
28 changes: 13 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ node_js:
# so that your addon works for all apps
- "10"

sudo: false
dist: trusty
dist: xenial

addons:
chrome: stable
Expand All @@ -26,42 +25,41 @@ branches:
- /^v\d+\.\d+\.\d+/

jobs:
fail_fast: true
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

include:
# runs linting and tests with current locked deps

- stage: "Tests"
name: "Tests"
install:
- yarn install --non-interactive
script:
- yarn lint:hbs
- yarn lint:js
- yarn test
- yarn lint
- yarn test:ember

- name: "Floating Dependencies"
- stage: "Additional Tests"
name: "Floating Dependencies"
install:
- yarn install --no-lockfile --non-interactive
script:
- yarn test
- yarn test:ember

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- stage: "Additional Tests"
env: EMBER_TRY_SCENARIO=ember-lts-2.16
- env: EMBER_TRY_SCENARIO=ember-lts-2.18
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
- env: EMBER_TRY_SCENARIO=ember-lts-3.16
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
- env: EMBER_TRY_SCENARIO=ember-classic

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH

install:
- yarn install --no-lockfile --non-interactive
- yarn install --non-interactive

script:
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
## Installation

* `git clone <repository-url>`
* `cd my-addon`
* `npm install`
* `cd ember-component-css`
* `yarn install`

## Linting

* `npm run lint:hbs`
* `npm run lint:js`
* `npm run lint:js -- --fix`
* `yarn lint:hbs`
* `yarn lint:js`
* `yarn lint:js --fix`

## Running tests

Expand All @@ -23,4 +23,4 @@
* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
63 changes: 0 additions & 63 deletions addon/initializers/component-styles.js

This file was deleted.

26 changes: 0 additions & 26 deletions addon/initializers/route-styles.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import initRouteStyles from '../utils/init-route-styles';
import addRouteStyleNamespace from 'ember-component-css/utils/add-route-style-namespace';
import addComponentStyleNamespace from 'ember-component-css/utils/add-component-style-namespace';


// This file is removed from the build in Ember < 3.6
export function initialize(appInstance) {
let router = appInstance.lookup('service:router');
router.on('routeDidChange', function({ to }) {
if (likeRouteInfo(to)) {
initRouteStyles(appInstance, nestedRouteNames(to));
addRouteStyleNamespace(appInstance, nestedRouteNames(to));
}
});

Expand All @@ -16,10 +17,12 @@ export function initialize(appInstance) {
// loading route names are set with an _loading even though
// their path is -loading
.map(name => name.replace(/_loading$/, '-loading'));
initRouteStyles(appInstance, routeNames);
addRouteStyleNamespace(appInstance, routeNames);
}
}
});

addComponentStyleNamespace(appInstance);
}

function nestedRouteNames({ name, parent }, routeNames = []) {
Expand All @@ -31,9 +34,9 @@ function nestedRouteNames({ name, parent }, routeNames = []) {
}

function likeRouteInfo(info) {
return info && typeof info === 'object' && info.hasOwnProperty('name');
return info && typeof info === 'object' && Object.prototype.hasOwnProperty.call(info, 'name');
}

export default {
initialize
};
}
3 changes: 0 additions & 3 deletions addon/mixins/style-namespacing-extras.js

This file was deleted.

8 changes: 8 additions & 0 deletions addon/modifiers/style-namespace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { modifier } from 'ember-modifier';

export default modifier(function styleNamespace(element, classAppends = [], { buildClass, argsClass, runClass }) {
const mainClassNmae = argsClass || runClass || buildClass;
const className = [mainClassNmae, ...classAppends].join('');

element.classList.add(className);
});
1 change: 0 additions & 1 deletion addon/pod-names.js

This file was deleted.

22 changes: 22 additions & 0 deletions addon/utils/add-component-style-namespace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import processStyleType from 'ember-component-css/utils/process-style-type';

export default function addComponentStyleNamespace(owner) {
const styles = processStyleType(owner);

for (const styleFullName of styles) {
const component = owner.lookup(`component:${styleFullName}`);
const { styleNamespace } = owner.lookup(`style:${styleFullName}`) || {};

if (styleNamespace && component) {
const proto = Object.getPrototypeOf(component);

if (!component.styleNamespace) {
proto.styleNamespace = styleNamespace;
}

if (!component.classNameBindings.includes('styleNamespace')) {
proto.classNameBindings = component.classNameBindings.concat('styleNamespace');
}
}
}
}
17 changes: 17 additions & 0 deletions addon/utils/add-route-style-namespace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default function addRouteStyleNamespace(owner, routes) {
const classes = [];

for (const name of routes) {
const { styleNamespace } = owner.lookup(`style:${name}`) || {};
const controller = owner.lookup(`controller:${name}`);

if (styleNamespace && controller) {
controller.set('styleNamespace', styleNamespace);
classes.push(styleNamespace);
}
}

if (owner.lookup('controller:application')) {
owner.lookup('controller:application').set('routeStyleNamespaceClassSet', classes.join(' '));
}
}
Loading