After reimplementing the fab speed dial based on the demo presneted on angular material, I've managed to set the position, but I can't seem to figure out how to setup the spacing between the dials.
They're really close to eachother. I've tried setting the margin and padding, but in the button, but it doesn't seem to be right, because it applies even in close mode, whereas intended only to be set in open mode.
Link to codepen demo of my code
HTML
<div ng-controller="DemoCtrl as demo" layout="column" ng-cloak="" class="fabSpeedDialdemoBasicUsage" ng-app="MyApp">
<div style="position: fixed; bottom: 15px; right: 50%" >
<md-fab-speed-dial md-open="demo.isOpen" md-direction="up"
class="md-fling" ng-cloak>
<md-fab-trigger >
<md-button aria-label="menu" class="md-fab md-warn" ng-style="navIconStyle" >
<md-icon md-svg-src="img/icons/menu.svg"></md-icon>
</md-button>
</md-fab-trigger>
<md-fab-actions>
<md-button ng-repeat="button in demo.pageButtons" class="md-fab md-raised md-icon-button "
aria-label="{{button.label}}" style="background-color:orange;margin-top:10px;">
<md-icon md-svg-icon="{{button.icon}}"></md-icon>
</md-button>
</md-fab-actions>
</md-fab-speed-dial>
</div>
</div>
JS
(function() {
'use strict';
angular.module('MyApp',['ngMaterial', 'ngMessages', 'material.svgAssetsCache'])
.controller('DemoCtrl', function() {
this.pageButtons =
[
{
icon: "img/icons/menu.svg",
label: "News"
},
{
icon: "img/icons/menu.svg",
label: "Schedule"
},
{
icon: "img/icons/menu.svg",
label: "Home"
}
]
});
})();
You can create a ng-style that corresponds to an array of styles
Since we're focused on the speed dial, the open state and close state depends on directive's argument md-open, which here is assigned by isOpen.
So when isOpen = true, then we can set 10px padding, otherwise if close, then set padding to false, and make it 0px. We can do this by creating an array of those two css styles. Then cast the boolean value of isOpen state with an integer, so the array of style corresponds accordingly.
In Html's md-button tag
ng-style="navIconStyle[navController.isOpen ? 1 : 0]"
In Js controller
$scope.navIconStyle =
[
{
"margin-bottom" : "0px"
},
{
"margin-bottom" : "10px"
}
]
I tried adding ng-style, but it seems that Angular Material framework overwrites the style while expanding. I ended up adding a separate class and using ng-class attribute.
ng-class="{'spaced': demo.isOpen }"
And define the class as below. Use appropriate side of margin based on where FAB is opening. My case, menu was configured to open on left, so I set margin on right.
.md-button.md-fab.md-mini.spaced {
margin-right: 8px !important;
}
Related
I want to just set the left value of a absolutely positioned div different from other divs. I tried the last: property of tailwind, but its not working.
Here's my code thet I tried
absolute z-10 -ml-4 transform px-2 w-screen max-w-md sm:px-0 lg:ml-0 -left-5 last:left-20"
I added these classes and only want the last mapped div to have different position
Sample code:
<div class='relative w-full h-72'>
{items.map((each, i ) => {
return (
<div key={i} class='absolute top-0 left-0 last:left-10'>{each}</div
)
})}
</div>
and the last div that is mapped should have different left value
Prior to v2.1 and JIT mode, you need to explicitly enable the last-child variant in your tailwind.config.js, as it's not enabled for any core plugins.
// tailwind.config.js
module.exports = {
// ...
variants: {
extend: {
inset: ['last']
}
}
}
Playground demo: https://play.tailwindcss.com/Wt6reZBsRY
From v2.1, when using Just-in-Time mode no extra configuration is required as all styles are generated on-demand.
// tailwind.config.js
module.exports = {
mode: 'jit',
// ...
}
I have modal in which i have angular-material autocomplete. It's html is like this
<mat-form-field class="example-full-width dummy-input-field" floatLabel="never">
<input matInput class="custom-input" (blur)="getValue()" [matAutocomplete]="auto" [formControl]="stateCtrl">
</mat-form-field>
<mat-autocomplete #auto="matAutocomplete" style="z-index: 2000;">
<mat-option *ngFor="let state of filteredStates | async" [value]="state.name">
<img class="example-option-img" aria-hidden [src]="state.flag" height="25">
<span>{{state.name}}</span> |
<small>Population: {{state.population}}</small>
</mat-option>
</mat-autocomplete>
But issue here is that my autocomplete results list is showing behind modal like this
You can see at the top left behind screen overlay there is a list showing. Basically this list is of material-autcomplete suggestion list. I have tried these css to change z-index of autocomplete
.md-autocomplete-suggestions-container {
z-index: 100000 !important;
}
.cdk-overlay-container {
z-index: 999999 !important;
}
But none of the solution is working. I am not using bootstrap moda. I am using npm simple-modal. How can i fix this issue?
in your scss or css file of component add below
/deep/ .cdk-overlay-container { z-index: 9999; }
We need to get the bootstrap's z-index dynamically and increment it with some arbitrary number and set to the time-picket something like below:
$(document).on('show.bs.modal', '.modal', function (event) {
const zIndex = 1045 + (10 * $('.modal:visible').length);
// this zIndex can be assigned to the time-picker
$(this).css('z-index', zIndex);
setTimeout(function () {
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
}, 0);
});
This will solve your problem, but I suggest to use only one UI lib for the design :)
In my project, I use a bootstrap popover to show a table which populates through knockout observableArray. My problem is, it shows popover correctly to 'hover' but not to the 'focus'
This is my anchor link which triggers the popover.
<a style="cursor: pointer; font-weight: 100" data-bind="event: { mousedown: TndTrainingRegisterAdmin.ShowSchedule } , attr: { id: 'schedule' + appId()}" data-toggle="popover" data-trigger="focus" data-placement="right" data-html="true"> View Schedule </a>
I tried removing data-trigger="focus" and adding only one side of the code. it also didn't work out. So it's not due to code repetitions.
This is the knockout model's side code.
var ctrlId = '#schedule' + rs.appId();
$(ctrlId).popover(
{
template: '<div class="popover" role="tooltip" style="width: 100%; max-width:600px"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"><div class="data-content"></div></div></div>',
html: true,
content: function () {
return $('#divViewSchedule').html();
}
});
This is div code which contains the table.
<div id="divViewSchedule" class="hide">
#Html.Partial("~/Views/TrainingRegistration/_CourseSchedule.cshtml")
</div>
This popover works fine when I use data-trigger='hover' or trigger: 'hover' But I want it to work as 'focus' behavior. I tried adding data-trigger='focus' and trigger: 'focus' none of these working neither showing any errors in console.
Can Anyone help me, please? :)
Everything works very nice, but when you click outside the autocomplete input the text gets invisible, if you click in the input it goes black again and you see it is there.
Here is my html:
<body ng-app='myapp' layout="column" ng-controller="autocompleteController as ctrl">
<md-content layout-align="center" layout="row">
<md-input-container style="background-color: #3C83E1; padding: 1vh 1vh 1vh 1vh" flex="33" class="md-whiteframe-4dp">
<div layout="row" layout-align="center center" style="margin-bottom: 1vh; margin-top: 1vh">
<img src="http://www.simplesdental.com/assets/img/simplesdental-logo-b.svg">
</div>
<md-autocomplete
md-no-cache="ctrl.noCache"
md-autoselect="true"
md-search-text="ctrl.searchText"
md-items="item in ctrl.queryProcurar(ctrl.searchText)"
md-item-text="item.name"
md-floating-label="Nome do Paciente"
>
<span md-highlight-text="ctrl.searchText">{{item.name}}</span>
<md-not-found>
Não foi encontrado um paciente com o nome "{{ctrl.searchText}}".
</md-not-found>
</md-autocomplete>
</md-input-container>
and my js:
angular.module('myapp', ['ngMaterial'])
.controller("autocompleteController", function ($http) {
Object.filter = function (obj, predicate) {
var result = {}, key;
for (key in obj) {
if (obj.hasOwnProperty(key) && !predicate(obj[key])) {
result[key] = obj[key];
}
}
return result;
};
this.queryProcurar = function (query) {
return $http.get("https://jsonplaceholder.typicode.com/users")
.then(function (response) {
var res = response.data.filter(function (obj) {
return obj.name.toLowerCase().indexOf(query.toLowerCase()) != -1;
});
return res;
})
}
})
here, a demo: http://codepen.io/iurypiva/pen/YZQeBN
Since I was using this in an ng-repeat, I didn't want to give the same id to multiple elements in order to style it, so I looked further.
The problem actually turns out that the input portion of the md-autocomplete is wrapped in its own md-input-container. The css in question checks to see if there is an input inside an md-input-container that does not have the md-input-has-value class. The outside one (yours and mine) does not, just the inside one.
So I had choices.
I could remove the md-input-container and make it a div, as suggested in another answer. However, because I have a few other inputs inside md-input-containers already in my page, and because the md-autocomplete would not be inside the md-input-container (just the input inside it), I'd have to duplicate all the styling that md-input-container uses (text-align: vertical; padding: 2px; etc.).
Or I could add class="md-input-has-value" to my md-input-container.
I went the simpler route.
<md-input-container class="md-input-has-value">
<md-autocomplete ...
See modified your codepen
The problem is that md-input-container and md-floating-label has some weird conflicts in their css. Solved it changing de md-container to a simple div
The problem is actually just a CSS/styling issue
The easiest way to address this would be to use angular material's md-input-id attribute that is available for md-autocomplete (documentation here)
<md-autocomplete
md-input-id="searchinput"
md-autoselect="true"
md-search-text="ctrl.searchText"
md-items="item in ctrl.queryProcurar(ctrl.searchText)"
md-item-text="item.name"
md-floating-label="Nome do Paciente">
this attaches an ID (in my example I just called it searchinput) to the input that gets auto-generated by md-autocomplete that you can use to style the input.
The CSS that I tried in your codepen was then simply:
#searchinput { color: white; }
here is a fork of your codepen with these updates
Is it possible to bind a state (attribute) of a paper-checkbox [checked|unchecked] dynamically to an attribute like [readonly|disabled] inside a paper-input element? This is my implementation so far:
<template repeat="{{item in lphasen}}">
<div center horizontal layout>
<paper-checkbox unchecked on-change="{{checkStateChanged}}" id="{{item.index}}"></paper-checkbox>
<div style="margin-left: 24px;" flex>
<h4>{{item.name}}</h4>
</div>
<div class="container"><paper-input disabled floatingLabel id="{{item.index}}" label="LABEL2" value="{{item.percent}}" style="width: 120px;"></paper-input></div>
</div>
</template>
The behavior should be as follow:
When the user uncheck a paper-checkbox, then the paper-input element in the same row should be disabled and/or readonly and vice versa. Is it possible to directly bind multiple elements with double-mustache or do I have to iterate the DOM somehow to manually set the attribute on the paper-input element? If YES, could someone explain how?
Another way to bind the checked state of the paper-checkbox.
<polymer-element name="check-input">
<template>
<style>
#checkbox {
margin-left: 1em;
}
</style>
<div center horizontal layout>
<div><paper-input floatingLabel label="{{xlabel}}" value="{{xvalue}}" disabled="{{!xenable}}" type="number" min="15" max="200"></paper-input></div>
<div><paper-checkbox id="checkbox" label="Enable" checked="{{xenable}}"></paper-checkbox></div>
</div>
</template>
<script>
Polymer('check-input', {
publish:{xenable:true, xvalue:'',xlabel:''}
});
</script>
</polymer-element>
<div>
<check-input xenable="true" xvalue="100" xlabel="Weight.1"></check-input>
<check-input xenable="false" xvalue="185" xlabel="Weight.2"></check-input>
</div>
jsbin demo http://jsbin.com/boxow/
My preferred approach would be to refactor the code to create a Polymer element responsible for one item. That way, all of the item specific behaviour is encapsulated in one place.
Once that is done, there are a couple ways of doing this.
The easiest would be to simply create an on-tap event for the check box that toggles the value of a property and sets the disabled attribute accordingly.
<paper-checkbox unchecked on-tap="{{checkChanged}}"></paper-checkbox>
//Other markup for item name display
<paper-input disabled floatingLabel id="contextRelevantName" style="width:120 px;"></paper-input>
One of the benefits of putting this into it's own polymer element is that you don't have to worry about unique id's anymore. The control id's are obfuscated by the shadowDOM.
For the scripting, you would do something like this:
publish: {
disabled: {
value: true,
reflect: false
}
}
checkChanged: function() {
this.$.disabled= !this.$.disabled;
this.$.contextRelevantName.disabled = this.$.disabled;
}
I haven't tested this, so there might be some tweaks to syntax and what have you, but this should get you most of the way there.
Edit
Based on the example code provided in your comment below, I've modified your code to get it working. The key is to make 1 element that contains an either row, not multiple elements that contain only parts of the whole. so, the code below has been stripped down a little bit to only include the check box and the input it is supposed to disable. You can easily add more to the element for other parts of your item displayed.
<polymer-element name="aw-leistungsphase" layout vertical attributes="label checked defVal contractedVal">
<template>
<div center horizontal layout>
<div>
<paper-checkbox checked on-tap="{{checkChanged}}" id="checkbox" label="{{label}}"></paper-checkbox>
</div>
<div class="container"><paper-input floatingLabel id="contractedInput" label="Enter Value" value="" style="width: 120px;"></paper-input></div>
</div>
</template>
<script>
Polymer('aw-leistungsphase', {
publish: {
/**
* The label for this input. It normally appears as grey text inside
* the text input and disappears once the user enters text.
*
* #attribute label
* #type string
* #default ''
*/
label: '',
defVal : 0,
contractedVal : 0
},
ready: function() {
// Binding the project to the data-fields
this.prj = au.app.prj;
// i18n mappings
this.i18ndefLPHLabel = au.xlate.xlate("hb.defLPHLabel");
this.i18ncontractedLPHLabel = au.xlate.xlate("hb.contractedLPHLabel");
},
observe : {
'contractedVal' : 'changedLPH'
},
changedLPH: function(oldVal, newVal) {
if (oldVal !== newVal) {
//this.prj.hb.honlbl = newVal;
console.log("Geänderter Wert: " + newVal);
}
},
checkChanged: function(e, detail, sender) {
console.log(sender.label + " " + sender.checked);
if (!this.$.checkbox.checked) {
this.$.contractedInput.disabled = 'disabled';
}
else {
this.$.contractedInput.disabled = '';
}
console.log("Input field disabled: " + this.$.contractedInput.disabled);
}
});
</script>
</polymer-element>