Stylus mixin to alternate rules in nested classes of the same name? - stylus

What would be a smooth stylus (or sass) mixin to alternate rules in nested classes of the same name?
.ember-view
border: 1px solid red
.ember-view
border: 1px solid white
.ember-view
border: 1px solid blue
.ember-view
// repeat? options etc.
I've tried a few things to no avail and just went back to nesting 10 deep to avoid wasting time... however - I believe that someone out there has the answer.
alterate-border-color(a, b, c, ...)
// logic
// border-color: 1px solid n
.ember-view
alternate-border-color('red', 'white', 'blue')
Answered! by #blonfu: here is a CodePen with an example

Finally I archieve a solution. The problem was prevent repeat the entire selector in each iteration of the loop, I just needed to repeat .ember-view selector and I use a little weird code to get that. I hope it is useful for you:
Stylus
alterate-border-color(colors...)
$selector = selector()
for color in colors
/{$selector}
border-color: 1px solid color
$selector = $selector + " " + selector()
.ember-view
alterate-border-color(red , blue, yellow, green)
CSS output
.ember-view {
border-color: 1px solid #f00;
}
.ember-view .ember-view {
border-color: 1px solid #00f;
}
.ember-view .ember-view .ember-view {
border-color: 1px solid #ff0;
}
.ember-view .ember-view .ember-view .ember-view {
border-color: 1px solid #008000;
}

Related

can't show caret icon for sorting beside the column name

I can't show caret icon for sorting beside the column name using react-bootstrap-table2 even i set the attribut sort to true in columns.
Thank you
Hopefully this link will solve your problem https://github.com/react-bootstrap-table/react-bootstrap-table2/issues/215
If, by default, the caret is missing, you may add the following styles to your global stylesheet.
.caret {
display: inline-block;
width: 0;
height: 0;
margin-left: 2px;
vertical-align: middle;
border-top: 4px dashed;
border-top: 4px solid \9;
border-right: 4px solid transparent;
border-left: 4px solid transparent;
}

Add width between table headers in Custom Table Form

Using Example from SO Table Form
I successfully implemented the form in my component as per my need. The only thing bugging me is there is no gap between the headers and I can't seem to figure out on how to do that as it looks very odd.
As you can see in the highlighted it looks very weird with no gap between headers.
Working codebox
Please do let me know if anyone figures out on how to do that.
I tried:
formtable.css:
table {
border-collapse: separate;
border-spacing: 30px;
}
and it does provides space between header but it looks more ugly as header shifts to left and when clicking on add address inside form looks weird.
Well, you have not applied any styles. That says it all.
I have added some basic styling for your reference, you can style per your need.
Check the working example here
.App {
font-family: sans-serif;
text-align: center;
padding: 1rem;
}
table {
border-spacing: 0;
border: 1px solid black;
}
tr:last-child td {
border-bottom: 0;
}
th,
td {
margin: 0;
padding: 0.5rem;
border-bottom: 1px solid black;
border-right: 1px solid black;
}
th:last-child {
border-right: 0;
}
td:last-child {
border-right: 0;
}

Displaying up/down arrows in angular js

I have created table with sorter in angular js. But I am unable to display up/down arrows to my code.What did I do wrong?
var app=angular.module("myModule",[])
.controller("myController",function($scope){
var employees=[
{name:"suha",dob:new Date("november,20,1995"),gender:"female",salary:"57300.00"},
{name:"Yashu",dob:new Date("august,25,1997"),gender:"female",salary:"47653.0000"},
{name:"sneha",dob:new Date("july,30,1999"),gender:"female",salary:"43300.00"}
];
$scope.employees=employees;
$scope.sortColumn="name";
$scope.reverseSort=false;
$scope.sortData=function(column){
$scope.reverseSort=($scope.sortColumn==column)? !$scope.reverseSort : false;
$scope.sortColumn=column;
}
$scope.getSortClass=function(column){
if($scope.sortColumn==column){
return $scope.reverseSort ? 'arrow-down' : 'arrow-up';
}
return '';
}
});
table,tr,td{
border:1px solid;
padding:10px;
}
.arrow-up,.arrow-down{
width:0;
height:0;
border-right: 5px transparent;
border-left: 5px transparent;
border-bottom-color: 10px solid black;
display: inline-block;
}
Complete code: https://jsfiddle.net/4vy9m3h1/
Add ng-class to th like below
<th ng-click="sortData('name')" ng-class="getSortClass('name')">
Name
</th>
See the working fiddle
Updated fiddle with arrow icons:
The problem actually lies on your CSS. This should work:
table,tr,td{
border:1px solid;
padding:10px;
}
.arrow-up{
width:10px;
height:10px;
border-right: 5px solid transparent;
border-left: 5px solid transparent;
border-bottom: 10px solid black;
display: inline-block;
}
.arrow-down{
width:0;
height: 0;
border-right: 5px solid transparent;
border-left: 5px solid transparent;
border-bottom: 10px solid black;
display: inline-block;
}
You've entered a wrong property/value, i.e. using shorthand within this property border-bottom-color.

Why does link tooltip disappear the moment I take my mouse off of the link symbol in the toolbar?

To test links in my Quilljs editor, I'm highlighting text and then clicking the link symbol in the toolbar -- for a split second the link tooltip shows up, only to disappear right away unless I hold my click on the symbol.
It appears that there's a 'ql-hidden' class that's being applied wrongly, but I'm not sure if it's something to do with my configuration being incorrect.
Here's the JavaScript:
var primaryQuill = new Quill('#editor', {
modules: {
toolbar: '#toolbar',
'link-tooltip': true
},
theme: 'snow'
});
Here's the HTML (using the Jade templating language):
#toolbar
span.ql-format-group
button.ql-bold(type="button") Bold
button.ql-italic(type="button") Italic
span.ql-format-group
button.ql-link(type="button") Link
#editor
p Start writing here...
And here are the only styles I've written for this:
.ql-toolbar {
background: #fff !important;
box-shadow: 1px 1px 3px 1px rgba(0,0,0,.1) !important;
margin: 5px 0px !important;
border: none !important;
}
.ql-container {
margin: -5px 0px !important;
background: #fff !important;
border: none !important;
box-shadow: 1px 2px 3px 1px rgba(0,0,0,.2) !important;
min-height: 500px;
font-size: 1.2em !important;
font-family: inherit !important;
color:rgba(0,0,0,.8) !important;
}

Select2: how to add custom styling to the option that doesn't exist in the dropdown?

I am using select2. I've enabled users to select keywords that doesn't match. Just wondering when someone does type something that doesn't match, how do you style the dropdown item that's not matching to show a different style? I would like to gray it out or make it italic or something.
Heres an example, the 1st dropdown item doesn't match anything else in the dropdown:
I'm using Angular, but I'm happy for anyone with jQuery solutions to answer as well. I can appropriate it for Angular.
you will want to use the formatResult option, along with styling the result using the markMatch internal function of select2 to retain underline function (see https://groups.google.com/forum/#!topic/select2/FhVygJ_21Nk )
This is an example of code i did to style user input than did not match the queried list of tags. I also included the count of the number of times the tag was used
...
formatResult: function(result, container, query, escapeMarkup) {
var markup=[];
window.Select2.util.markMatch(result.text, query.term, markup, escapeMarkup);
if (result.isNew) {
return markup.join("");
} else {
return '<span class="post-tag">'+markup.join("")+'</span><span class="item-multiplier">× '+result.count+'</span>';
}
},
...
css for my above example
<style>
.item-multiplier {
font-size: 90%;
font-weight: normal;
margin-right: 4px;
color: #999;
}
.post-tag, .post-text .post-tag, .wmd-preview a.post-tag {
padding: 3px 4px 3px 4px;
margin: 2px 2px 2px 0;
position: relative;
text-decoration: none;
font-size: 100%;
line-height: 1.4;
white-space: nowrap;
color: #333;
cursor: default;
border: 1px solid #aaaaaa;
border-radius: 3px;
-webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
background-clip: padding-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: #e4e4e4;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
background-image: linear-gradient(to top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
}
.select2-results .select2-highlighted {
background: #fff0d9;
color: #000;
}
.select2-result-selectable .select2-match, .select2-result-unselectable .select2-match {
font-weight: bold;
}
</style>

Resources