Displaying up/down arrows in angular js - angularjs

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.

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;
}

how to add error class on an input and override style with scss?

this is my css:
input[type="text"] {
.has-error {
color: red;
border: 1px solid red;
}
}
input[type="text"],
textarea {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #446a63;
outline: none;
}
this is my react code:
<input
className={classNames({
"has-error": true,
})}
type="text"
placeholder="Name"
value={values.name}
onBlur={handleBlur("name")}
onChange={handleChange("name")}
/>
but that don't work, this does, but only changes the color and not override the border?, i want to override the border above of it and also nest it inside input type since it's only specific for inputs?:
input[type="text"],
textarea {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #446a63;
outline: none;
}
.has-error {
color: red;
border: 1px solid red;
}
In CSS, the selector for input[type="text"] is more specific than one for just a css class as .has-error. Therefore the tag style overrides the class style (you should be able to see this in your dev console).
So you could fix your code with a more explicit selector, directly referencing both tag and class:
input[type="text"].has-error,textarea.has-error
input[type="text"],
textarea {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #446a63;
outline: none;
}
input[type="text"].has-error,
textarea.has-error {
color: red;
border: 1px solid red;
}

CSS module `:hover .child` not working

I have the following scss:
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 1em;
&:hover {
padding: 3em;
.d-none {
display: inline-block !important;
}
}
&:hover .d-none {
display: inline-block !important;
}
}
On hover, I get the padding:3em but both the nested, and inline child rule didn't work, ie .d-none class wasn't overridden.
What's the right way of writing the rule with CSS module?
I'm trying out CSS module with CRA and custom-react-scripts with sass and modules turned on (REACT_APP_SASS_MODULES=true).
Or perhaps I should use styled components instead? Was trying to figure out which one to go for for react apps.
you can try this code to solve your problem
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 3em;
background: red;
&:hover {
&.d-none {
background: black;
color: #fff;
padding: 20px;
}
}
}
.d-none {
background: green;
color: #fff;
padding: 20px;
}
<div class="skillBox">
Parrent
<div class="d-none">Childred</div>
</div>
Exmaple :: https://codepen.io/anon/pen/yqQNJXCodePen
There's nothing wrong with your CSS. See the demo below.
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 1em;
.d-none{
display: none;
}
&:hover {
padding: 3em;
.d-none {
display: inline-block;
}
}
}
https://codepen.io/paulcredmond/pen/djQoow
In case if element with skillbox and d-none class are siblings below is the css for that
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 1em;
&:hover {
padding: 3em;
}
}
.dnone {
display: none;
}
.skillBox:hover ~ .dnone {
display: inline-block;
}
http://jsbin.com/hixamotuku/edit?html,css,output
So I realise CSS Modules created a customised classname for .d-none and applying that classname worked.
So I changed the classname altogether making it an entirely new class that overrides .d-none.
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 1em;
&:hover {
.dNone {
display: inline-block !important;
}
}
}
And applying by adding them as an array then joining them together:
<i className={['fas fa-times-circle d-none', styles.faTimesCircle, styles.dNone].join(' ')} onClick={this.onDelete} />

AngularJS - Sliding down menu on ng-click

I have a menu button that on ng-click used to show and hide. How can i adapt this so that on ng-click the menu slides down and up on close?
HTML:
<div class="nav">
<nav class="primary-nav" ng-show="showMenu" ng-class="{true: 'showMenu'}[showMenu]">
<ul>
<li>Desktop Site</li>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
</nav>
<div class="nav-slide"> Menu
</div>
CSS:
.nav {
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 10;
}
.primary-nav {
width: 100%;
background: #fff;
}
.primary-nav a { display: block; padding: 15px 8px; border-bottom: 1px solid #D1D1D1; color: #666666; font-weight: 700; }
.primary-nav li:last-child a { border-bottom: none; }
.nav-slide {
position: relative;
top: 0;
border-top: 4px solid #fff;
-webkit-box-shadow: 0px 5px 4px 0px #000;
box-shadow: 0px 5px 4px 0px #000;
z-index: 10;
}
.nav-slide a {
display: block;
width: 80px;
position: relative;
right: 10px;
padding: 2px 0 8px 0;
float: right;
text-align: center;
color: #333;
font-weight: 700;
border-radius: 0 0 6px 6px;
-webkit-box-shadow: 0px 5px 4px 0px #000;
box-shadow: 0px 5px 4px 0px #000;
}
.nav-slide a.active { background-position: center -24px }
.showMenu {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
}
Here's a link to a plunker: http://plnkr.co/edit/NvWW0x2d8NPNJAIfDN5F
To get CSS animations working, you need to drop ng-show/ng-hide on the animated element and do everything with CSS classes. Here is an example of what I did, it's still not finished because you have some complex stuff there, but hopefully it's enough to get you started:
HTML
<nav class="primary-nav" ng-class="{true: 'showMenu'}[showMenu]">
CSS
.primary-nav {
width: 100%;
background: #fff;
height: 0;
transition: all 0.5s linear;
}
.primary-nav.showMenu {
height: 150px;
}
.primary-nav li { display: none; }
.primary-nav.showMenu li { display: initial; }
See it live here: http://plnkr.co/edit/TK5hX3MXPHBnIwVDNifK?p=preview
Animating margins instead of height here: http://plnkr.co/edit/VMdUALUbhqIpOPfNGDyU?p=preview

Tree built with Twitter Bootstrap and Backbone.js?

Is there a simple modular tree built with Twitter Bootstrap and Backbone.js that provides common tree control functionality?
Here's a Bootstrap tree widget (from "Trees in Twitter Bootstrap"):
Building on Vitaliy's CSS and Mehmet's jQuery, I changed the a tags to span tags and incorporated some Glyphicons and badging into my take on a Bootstrap tree widget.
Example:
For extra credit, I've created a GitHub project to host the jQuery and LESS code that goes into adding this tree component to Bootstrap. Please see the project documentation at http://jhfrench.github.io/bootstrap-tree/docs/example.html.
Alternately, here is the LESS source to generate that CSS (the JS can be picked up from the jsFiddle):
#import "../../../external/bootstrap/less/bootstrap.less"; /* substitute your path to the bootstrap.less file */
#import "../../../external/bootstrap/less/responsive.less"; /* optional; substitute your path to the responsive.less file */
/* collapsable tree */
.tree {
.border-radius(#baseBorderRadius);
.box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
background-color: lighten(#grayLighter, 5%);
border: 1px solid #grayLight;
margin-bottom: 10px;
max-height: 300px;
min-height: 20px;
overflow-y: auto;
padding: 19px;
a {
display: block;
overflow: hidden;
text-overflow: ellipsis;
width: 90%;
}
li {
list-style-type: none;
margin: 0px 0;
padding: 4px 0px 0px 2px;
position: relative;
&::before, &::after {
content: '';
left: -20px;
position: absolute;
right: auto;
}
&::before {
border-left: 1px solid #grayLight;
bottom: 50px;
height: 100%;
top: 0;
width: 1px;
}
&::after {
border-top: 1px solid #grayLight;
height: 20px;
top: 13px;
width: 23px;
}
span {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #grayLight;
border-radius: 5px;
display: inline-block;
line-height: 14px;
padding: 2px 4px;
text-decoration: none;
}
&.parent_li > span {
cursor: pointer;
/*Time for some hover effects*/
&:hover, &:hover+ul li span {
background: #grayLighter;
border: 1px solid #gray;
color: #000;
}
}
/*Remove connectors after last child*/
&:last-child::before {
height: 30px;
}
}
/*Remove connectors before root*/
> ul > li::before, > ul > li::after {
border: 0;
}
}
I recently published my backbone.js tree widget.Check it out at https://bitbucket.org/dnation/bbtree/ and see if it meets your needs.

Resources