gwt gss lighten() and darken() - gwt

i was trying to use lighten() and darken() in GSS (i'm gwt 2.8 version and material-design rc4) like so:
#def MAIN_COLOR #64b5f6;
#def LIGHTER_COLOR lighter(MAIN_COLOR, 0.5);
.lighter {
color: LIGHTER_COLOR;
}
but the result is
.lighter {
color: lighter(#64b5f6,0.5)
}
i cannot find any sample of using those functions anywhere..
https://github.com/google/closure-stylesheets
i was expecting that those work like in SASS
$primary-color: #64b5f6;
$darken: darken($primary-color, 7%);
$lighten: lighten($primary-color, 20%);
thanks.

I can't reproduce your exact behaviour, but I have managed to get a working example and found the following:
The function name is lighten
The lighten function takes an integer number between 0 and 100 as the amount to lighten by. This is documented directly in the code on GitHub.
I've tried modifying your example as follows and it is working fine:
#def MAIN_COLOR #64b5f6;
#def LIGHTER_COLOR lighten(MAIN_COLOR, 5);
.lighter {
color: LIGHTER_COLOR;
}
This is evaluated, using the latest version of Closure Stylesheets (right now,
v1.4.0) to become the following:
.lighter{color:#7cc1f7}
I expect the number is a percentage lightness increase - that's the method I use in my own color software and is generally what other CSS preprocessor lightening/darkening functions use too - so you might need to play around to get the exact shade you're looking for.
I hope it works for you.

Related

VsCode Extension custom CompletionItem disables built-in Intellisense

I am working on a VsCode extension in that I want to provide custom snippets for code completion.
I know about the option of using snippet json files directly, however those have the limitation of not being able to utilize the CompletionItemKind property that determines the icon next to the completion suggestion in the pop-up.
My issue:
If I implement a simple CompletionItemProvider like this:
context.subscriptions.push(
vscode.languages.registerCompletionItemProvider(
{scheme:"file",language:"MyLang"},
{
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
let item = new vscode.CompletionItem('test');
item.documentation = 'my test function';
item.kind = vscode.CompletionItemKind.Function;
return [item];
}
}
)
)
then the original VsCode IntelliSense text suggestions are not shown anymore, only my own. Should I just return a kind of an empty response, like
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
return [null|[]|undefined];
}
the suggestions appear again as they should. It seems to me that instead of merging the results of the built-in IntelliSense and my own provider, the built-in ones get simply overridden.
Question:
How can I keep the built-in IntelliSense suggestions while applying my own CompletionItems?
VsCode Version: v1.68.1 Ubuntu
I seem to have found the answer for my problem, so I will answer my question.
Multiple providers can be registered for a language. In that case providers are sorted
by their {#link languages.match score} and groups of equal score are sequentially asked for
completion items. The process stops when one or many providers of a group return a
result.
My provider seems to provide results that are just higher scored than those of IntelliSense.
Since I didn't provide any trigger characters, my CompletionItems were comteping directly with the words found by the built-in system by every single pressed key and won.My solution is to simply parse and register the words in my TextDocument myself and extend my provider results by them. I could probably just as well create and register a new CompletionItemProvider for them if I wanted to, however I decided to have a different structure for my project.

Stop huge error output from testing-library

I love testing-library, have used it a lot in a React project, and I'm trying to use it in an Angular project now - but I've always struggled with the enormous error output, including the HTML text of the render. Not only is this not usually helpful (I couldn't find an element, here's the HTML where it isn't); but it gets truncated, often before the interesting line if you're running in debug mode.
I simply added it as a library alongside the standard Angular Karma+Jasmine setup.
I'm sure you could say the components I'm testing are too large if the HTML output causes my console window to spool for ages, but I have a lot of integration tests in Protractor, and they are SO SLOW :(.
I would say the best solution would be to use the configure method and pass a custom function for getElementError which does what you want.
You can read about configuration here: https://testing-library.com/docs/dom-testing-library/api-configuration
An example of this might look like:
configure({
getElementError: (message: string, container) => {
const error = new Error(message);
error.name = 'TestingLibraryElementError';
error.stack = null;
return error;
},
});
You can then put this in any single test file or use Jest's setupFiles or setupFilesAfterEnv config options to have it run globally.
I am assuming you running jest with rtl in your project.
I personally wouldn't turn it off as it's there to help us, but everyone has a way so if you have your reasons, then fair enough.
1. If you want to disable errors for a specific test, you can mock the console.error.
it('disable error example', () => {
const errorObject = console.error; //store the state of the object
console.error = jest.fn(); // mock the object
// code
//assertion (expect)
console.error = errorObject; // assign it back so you can use it in the next test
});
2. If you want to silence it for all the test, you could use the jest --silent CLI option. Check the docs
The above might even disable the DOM printing that is done by rtl, I am not sure as I haven't tried this, but if you look at the docs I linked, it says
"Prevent tests from printing messages through the console."
Now you almost certainly have everything disabled except the DOM recommendations if the above doesn't work. On that case you might look into react-testing-library's source code and find out what is used for those print statements. Is it a console.log? is it a console.warn? When you got that, just mock it out like option 1 above.
UPDATE
After some digging, I found out that all testing-library DOM printing is built on prettyDOM();
While prettyDOM() can't be disabled you can limit the number of lines to 0, and that would just give you the error message and three dots ... below the message.
Here is an example printout, I messed around with:
TestingLibraryElementError: Unable to find an element with the text: Hello ther. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
...
All you need to do is to pass in an environment variable before executing your test suite, so for example with an npm script it would look like:
DEBUG_PRINT_LIMIT=0 npm run test
Here is the doc
UPDATE 2:
As per the OP's FR on github this can also be achieved without injecting in a global variable to limit the PrettyDOM line output (in case if it's used elsewhere). The getElementError config option need to be changed:
dom-testing-library/src/config.js
// called when getBy* queries fail. (message, container) => Error
getElementError(message, container) {
const error = new Error(
[message, prettyDOM(container)].filter(Boolean).join('\n\n'),
)
error.name = 'TestingLibraryElementError'
return error
},
The callstack can also be removed
You can change how the message is built by setting the DOM testing library message building function with config. In my Angular project I added this to test.js:
configure({
getElementError: (message: string, container) => {
const error = new Error(message);
error.name = 'TestingLibraryElementError';
error.stack = null;
return error;
},
});
This was answered here: https://github.com/testing-library/dom-testing-library/issues/773 by https://github.com/wyze.

VSCode JSDoc Multiline for Intellisense

I am looking to have JSON examples in my documentation, which in turn will have JSON examples in my intellisense for VScode.
I have tried every trick in the book that I can think of, is this possible to do with line breaks and things that would make the JSON readable? I cannot get this to work in VScode no matter what I do, it takes out white space and makes one line.
I try to do:
/**
* {
* "JSONData":"not going to format like this"
* }
*/
functionToDescribe()
this of course will end up in intellisense like so...
{ "JSONData":"not going to format like this" }
This is ok with small examples, but I would like to have a bit larger (still small) simple examples. There are other reasons I really want line breaks, not just JSON, I just want my text to be cleaner in my comments in general.
I will also take different examples of how other people document it. I am really looking to make my JS code easier to know what to expect the function to accept, return and use in operation before using it.
EDIT:
I stumbled across this link: https://github.com/Microsoft/vscode/issues/30062
which now I understand that formatting works when you look at the declaration of the function or item, but not when you go to use it.
the following markup code works great when I hover over the function name, but when I use it like normal it is all on one line and worthless
/** This is a description
* with each line
* on it's own
*
* #example Test
* ```javascript
* let valueReturned = false;
* jest.fn(() => {
* if (!valueReturned) {
* valueReturned = true;
* return value;
* //no idea why it requires me to have so many spaces...
* }
* });
* ```
*/
functionTest() //When hovering over this, it looks great
functionTest( //at this point intellisense pops up and is worthless
I believe this is a bug or simply bad design, maybe I will put in a feature request, if it doesn't already exist.
I will keep this question open in case someone else has any suggestions or possible work arounds.
EDIT:
Good news, it looks like this was a bug and after searching for quite a while, it seems this was fixed just this month and will be with the September release!
https://github.com/Microsoft/vscode/issues/1920
I will close this now and leave this up for anyone else who was having troubles with this.
This was a bug for the intellisense, which has been corrected as of 4 days ago, so it should be released soon, so if you can get the "hover" to look as you want, it should translate to the intellisense when the fix drops.
https://github.com/Microsoft/vscode/issues/1920

Static assets in play java

I have save path in database, when I use it in view
#for(photo <- photos){
<img src="#routes.Assets.versioned("images/photo.getPath()")" class="img-rounded" alt="Cinque Terre" width="304" height="236">
}
photo.getPath() is not working, I try with #photo.getPath() still not working. Any suggest for me. I use play-java version 2.5. Thank a lot.
Personally, I find the Twirl syntax a bit unintuitive. The # marks the start of a scala statement. The length of this statement is determined automatically.
Now looking at the img tag:
<img src="#routes.Assets.versioned("images/photo.getPath()")" class="img-rounded" alt="Cinque Terre" width="304" height="236">
the following piece of code should be identified as a single statement:
routes.Assets.versioned("images/photo.getPath()")
From a scala point of view, the "images/photo.getPath()" is just a String. It will not execute any method on the photo object. I think (I didn't test this) that your issue should be solveable by replacing this part by s"images/${photo.getPath()}". Note that the string interpolation will make sure that the method on the photo object will be called.
This would make your example look like:
#for(photo <- photos) {
<img src="#routes.Assets.versioned(s"images/${photo.getPath()}")" class="img-rounded" alt="Cinque Terre" width="304" height="236">
}

Mediawiki process tag after templates tranclusion

Is there any way to do something like that.
I have next wiki text:
{{template_open_tag}}
{{template_some_data}}
{{template_close_tag}}
And there are templates:
{{template_open_tag}}
<my-tag>
{{template_some_data}}
bla-bla-bla...
{{template_close_tag}}
</my-tag>
But tag '<bold>' processed already when first template transluded and wiki render this page like:
bla-bla-bla...
</my-tag>
But I want to see:
**bla-bla-bla...**
In my extension:
$wgHooks['ParserFirstCallInit'][] = 'myTagInit';
function myTagInit( &$parser ) {
$parser->setHook( 'my-tag', 'myTagRender' );
}
function myTagRender( $input, $args, $parser, $frame) {
return "**".$input."**";
}
Thank you.
P.S.
And don't ask me why I need this strange markup and don't want to use something like this:
{{template_tag|{{template_some_data}}}}
And {{template_open_tag}} like:
<my-tag>{{{1}}}</my-tag>
To warn you -- this sort of structure will likely be phased out entirely in future versions of MediaWiki, due to its inconsistent behavior and the difficulties it causes with structures like tags and sections.
The correct and future-proof way to do it is indeed to contain both your start and end in one template and pass the middle in as a parameter, eg {{template_tag|{{template_some_data}}}}
Set $wgUseTidy to true to make MediaWiki remove unclosed tags only after all the templates have been evaluated. Alternatively, you can use wikimarkup - as Adrian said - which does not suffer from this limitation.
Update: AFAIK XML-style extension tags are evaluated before way template including happens, so piecing them together from multiple templates is not possible. (Event <ext>{{{1}}}</ext> does not work pre-1.16, though you can make it work in 1.16 with recursiveTagParse.)
instead of using <bold> use ''' in both your {{template_open_tag}} and {{template_close_tag}} and it should render as bla-bla-bla...
Also, you can't do:
{{template_open_tag}}
{{template_some_data}}
{{template_close_tag}}
You have to do
{{template_open_tag}}{{template_some_data}}{{template_close_tag}}