Skip to content
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

text color change based on content #2

Open
vincenzodesanctis opened this issue Apr 11, 2017 · 2 comments
Open

text color change based on content #2

vincenzodesanctis opened this issue Apr 11, 2017 · 2 comments

Comments

@vincenzodesanctis
Copy link

vincenzodesanctis commented Apr 11, 2017

Congratulation! It's very cool.
I have a question: is there a easy way to chance text color based on text?

Example:

if text_match = 'world' than color yellow
result:

first row: "this is a test"---> color white 
second row: 'hello world!'  ----> color yellow

I think I should use this._element.appendChild on DepartureBoard.Letter, but I tried without sucessful.

thank you

@paulcuth
Copy link
Owner

You can either achieve this with CSS:

.row:nth-child(2) .letter {
	color: yellow;
}

...or with JavaScript. In the case of the demo, that would be:

// After the line: var board = new DepartureBoard(...);
board._element.querySelector('.row:nth-child(2)').style.color = 'yellow';

@vincenzodesanctis
Copy link
Author

Thank you for your quick answer!
Your great suggestion works well, but I'm looking for something like this:

board._element.querySelector(".row").should.have.text('world').style.color = 'yellow';

I mean, color yellow if the class .row contains the text 'world'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants