Bootstrap's LESS gradient mixins in bootstrap 3? [closed] - less

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
#btn-font-weight: normal;
#btn-default-color: #brand-primary;
#btn-default-bg: .#gradient.vertical(#brand-primary; #brand-secondary; 0%; 10%);
#btn-default-border: #ccc;

You can not save a LESS mixin output into a variable. Mixins are meant to be mixed into a rule. Read more on LESS: here.
In addition, bootstrap #btn-default-bg holds a color that is used for example by the .button-variant() mixin to set the background-color property, so it can not hold a gradient.
So, for making a button with the bootstrap mixin for gradient backgrounds you could try something along these lines (here I make a simple gradient button mixin, that you can use in buttons):
.gradient-button(#color, #borderColor, #startColor, #endColor, #startPercent, #endPercent, #degradeColor: #startColor) {
color: #color;
border-color: #borderColor;
background-color: #degradeColor;
#gradient > .vertical(#startColor, #endColor, #startPercent, #endPercent));
.reset-filter(); // Disable gradients for IE9 because filter bleeds through rounded corners
&:hover,
&:active {
color: #color;
border-color: darken(#borderColor, 12%);
background-color: darken(#degradeColor, 8%);
#gradient > .vertical(darken(#startColor, 8%), darken(#endColor, 8%), #startPercent, #endPercent);
.reset-filter();
}
}
Then you can use this mixin in your button like this:
/* your default button */
.btn-default {
.gradient-button(#brand-text-color, #brand-border, #brand-primary, #brand-secondary, 0%, 10%);
}
Or you can see how the .btn-styles() mixin is designed and used in the theme.less file.
A mixin can be reused in other buttons like the danger, success or info button. But you can in the same way (instead of building the mixin) just use the bootstrap gradient mixin directly in the button rule - if you are just defining one button.
To get some more ideas you can look into the button.less file or in mixins.less check out the .button-variants() mixin and see how you can make the above mixin also add some additional classes like .disabled and so on.

Related

Ability to disable text input in package "vue-search-select" - "basic-select" component

I want to disable text input in the "basic-select" component, from the "vue-search-select" package
because there are already ready-made styles for it, and I would not want to create a separate customized select
is it possible? Tell me please
I guess there is no explicit API to disable text input because this package is going to make a "searchable" select component. The text input can be hidden using CSS, however.
.search {
display: none;
}
/* or even better */
.ui.search.dropdown > input.search {
display: none;
}
However, you should be careful about the selector you choose. Depending on your project, it might have some side effects. It might be better to add a custom class to the component and use it as follows:
.my-custom-class .ui.search.dropdown > input.search {
display: none;
}

How to style Grid cell/row background without using classname generator

I searched a lot, but every solution was to include some constant CSS class names into the page, and use the Column's ClassNameGenerator to set the proper classname on the cell/row.
Now this might be a good solution when the developer can decide on formatting a cell, however when a user can decide (especially with a script written as cell renderer) how a cell will look like, it is not possible to use the ClassNameGenerator.
So question is, how can I format the cell/row background programmatically, not using any CSS? I can provide custom component as cell value. So it's fine to render a label with icon, or just icon, or a checkbox, however coloring this rendered component is not enough, since this is smaller than the cell itself, making it look really ugly. I need to access the root element of the cell, and color it using getStyle().set("background", "xxxx"). How to achieve this?
Thanks!
You can use a TemplateRenderer.
For example:
Grid<Person> grid = new Grid<>();
grid.setItems(people);
grid.addColumn(TemplateRenderer
.<Person>of("<b>[[item.name]]</b>")
.withProperty("name", Person::getName)
).setHeader("Name");
Checkout this tutorial for more information: https://vaadin.com/docs/v14/flow/components/tutorial-flow-grid
OK, finally I solved. I use a template renderer with a proper template structure. I modified the cell style in a way, that my renderer DIV fills the entire cell (removed any padding/margin from the original cells)
<dom-module id="grid-style" theme-for="vaadin-grid">
<template>
<style>
[part~='cell'] ::slotted(vaadin-grid-cell-content) {
padding: 0px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
--cellopa: 255;
}
[part~='cell'][aria-selected~="true"] ::slotted(vaadin-grid-cell-content) {
--cellopa: 0;
}
</style>
</template>
</dom-module>
I also added some simple CSS declarations to one of the main CSS:
vaadin-grid-tree-toggle flow-component-renderer {
width: 100%;
height: 100%;
}
vaadin-grid-cell-content flow-component-renderer {
width: 100%;
height: 100%;
flex-grow: 1;
}
This way the rendered DIV fills the whole cell and I can color it's background.
Now the problem comes with the selection, since the selection is not visible any more. For this you find the --cellopa variable set to 255 normally and set to 0 for selected cells.
Now when I define a background-color on the div, I use rgba and I set the alpha to the var(--cellopa) variable, like this for example rgba(255, 0, 0, var(--cellopa))
Now when the row is not selected, the cellopa is 255, so the background is visible, when I select the row the cellopa is set to 0, so the background of the DIV gets transparent, and the row selection color on the row is visible. This is super fast, and changing the selection does not cause any glitch, and also the previous coloring state is restored properly.
I also managed to get around with the treegrid and managed to color even the hierarchy column fully using a special template for the hierarchy column with some padding taking the level into account.

How to freeze first column in Fluent UI details list

How can I freeze the first column only in Fluent UI Details list? Columns are more than 40 . Hence needs to be frozen so that horizontal scroll can be used.
There is no direct way. But you can do it with some css hack. It's pretty much self explanatory.
.ms-DetailsRow-cell:first-child, .ms-DetailsHeader-cell:first-child {
position: sticky;
inset: 0;
background-color: white;
z-index: 1;
}

Dojo - Tree in accordion is broken (while outside is ok) , Why?

I've made simple application with dojo.
I took the exact same combo tree (cbtree) and put it once inside accordion and once first on page.
I don't understand why inside the accordion I get different cbTree (it looks really bad)
Here is online example of the problem :
http://77.235.53.170/cbTree/cbTree.htm
The problem is at your main.css, you have
#leftCol img {
width: 100%;
}
Which overwrites
.dijitFolderOpened, .dijitIconFolderOpen, .dijitIconError {
background-image: url("../../icons/images/commonIconsObjActEnabled.png");
width: 16px;
height: 16px;
}
You need resolve this in main.css by either removing your style, or changing it to a more specific rule; i.e. instead of #leftCol img, use #leftCol .yourClass.

Include a less file and pass parameters

I have a common.less file, that implements the basic CSS for different skins:
#textColor: black;
#iconSize: 16px;
.container: {
color: #textColor;
background-color: white;
}
.icon: {
width: #iconSize;
height: #iconSize;
}
// note that #iconSize is also used in this file inside mixins
The plan is to use it like so skin_1.less:
#iconSize: 32px; // override the icon size
// but leave #textColor as default
#import "common.less";
.container: {
color: red;
}
// I would now have big icons and red text
So I would like to have a common style, that I can reuse and selectively override variables.
This does not ssem to work however. I think it's because imports are always moved to the top, so variables cannot be pre-defined.
(I also read that variables are rather constants, so that may be another problem.)
Anyway: is there a better pattern to solve my use case?
You don't need to split the files up, just override the variable after the import. Variables are always resolved as the last definition, even if it is after where it is used.