FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(styling): Added 2 functions to control applicationAdditionalSelectors by NathanaelA · Pull Request #6124 · NativeScript/NativeScript · GitHub

feat(styling): Added 2 functions to control applicationAdditionalSelectors - #6124

Merged
vakrilov merged 14 commits into
NativeScript:masterfrom
NathanaelA:getAdditionalSelectors
Aug 2, 2018
Merged

vakrilov merged 14 commits into
NativeScript:masterfrom
NathanaelA:getAdditionalSelectors

Conversation

NathanaelA commented Jul 27, 2018
edited
Loading

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Somewhere between version 2.x of NativeScript and 4.x of NativeScript, the Styling system was changed. The application wide CSS selectors are no longer accessible from anything external to the style-scope file. (css selectors are now a local variable)

What is the new behavior?

I made a generic interface to be able to modify the applicationAdditionalSelectors basically I exposed two new functions off the StyleScope library;

  1. addTaggedAdditionalCSS this function accepts any CSS text and can set an optional Tag on the imported rules.
  2. removeTaggedAdditonalCSS this function will remove any CSS rules that were Tagged.

This is a much better solution to solve #5912 (just exposing the applicationAdditionalSelectors) -- this will allow anyone to easily add more CSS text "globally" to the app that can be optionally removed at some point in the future -- because the rules are tagged; you can add any number of different rule sets, and remove any set of them on demand at a later time.

Fixes/Implements/Closes #5912

Please note to test the new functionality; you can use the new version of NativeScript-Themes and the demo it has. (You'll have to run from master).

This does not create any breaking changes; and unless the functions are actually utilized they do not have any impact on the existing code base. If they are utilized then they will impact just the long term global selectors.

ghost added the ♥ community PR label Jul 27, 2018

Copy link
Copy Markdown
Contributor

test

This comment was marked as abuse.

This comment was marked as abuse.

dtopuzov commented Jul 27, 2018
edited
Loading

Copy link
Copy Markdown
Contributor

Hi @NathanaelA

Failing unit test:

Test: VIEW-LAYOUT-EVENT.test_event_LayoutChanged_IsNotRaised_TransformChanged FAILED:  Actual: <0>(number). Expected: <1>(number)

It might be some flakiness in unittest, passed after re-run.

This comment was marked as abuse.

Copy link
Copy Markdown
Contributor

@NathanaelA could you rebase latest master onto this PR?

vakrilov left a comment
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The 2 new methods seem useful for scenarios like the themes-switching, so 👍 the proposing them.

Can you add some unit-tests verifying that the methods work as expected? It is fairly isolated functionality so testing should be straight-forward.
You can extend the existing tests in style-tests.ts.

changed = true;
}
}
return changed;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Probably you should call mergeCssSelectors(); here again if there are changes.
It will regenerate the applicationCssSelectors and will increment applicationCssSelectorVersion.

This comment was marked as abuse.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Awesome!
For to operations (remove and after that add) the perf penalty won't be that big. If there are cases that you want to have multiple operations with tagged selectors - we can probably create an API that can batch these and call merge only once at the end.

This comment was marked as abuse.

ghost assigned vakrilov Jul 31, 2018
ghost added in progress and removed ♥ community PR labels Jul 31, 2018

vakrilov commented Aug 1, 2018

Copy link
Copy Markdown
Contributor

test

const css1 = "Label { color: #FF0000; }";
const css2 = "Label { color: #00FF00; }";
const css1 = "#test_checkAddRemoveCSS_label { color: #FF0000; }";
const css2 = "#test_checkAddRemoveCSS_label { color: #00FF00; }";

This comment was marked as abuse.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

buildUIAndRunTest will clear everything on the page (page-level CSS too), but will not clear the application-wide CSS selectors.
I noticed that the registered tag selectors remain which was affection other tests especially when running the tests with livesync. Thats why I made them specific id-selectors ;)

vakrilov merged commit 85b8c01 into NativeScript:master Aug 2, 2018
ghost removed the in progress label Aug 2, 2018

Copy link
Copy Markdown

Sorry if this is a dumb question... but do the two added functions need to be added to style-scope.d.ts as well?

lock Bot commented Nov 2, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock Bot locked and limited conversation to collaborators Nov 2, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Application CSS no longer exposed

7 participants


Back | FazBrowse Home | New Git URL