Div not confirming to grid. Defined an 8 column grid and elements are binding to 4 column. Susy - susy-compass

My div is not matching up to my grid. It's an 8 container grid and when I tell the element to span(2), it acts as if the grid were 4. Is this because I'm not defining a global grid in $susy?
Some contextual code:
First I defined a container grid:
#grid{
#include container(8);
gutter-width: 5%;
}
Then I added it to the html:
<main id="grid">...</div>
Then I nested the div in css:
#object1{
#extend %object;
#include span(2);
}
and added it to the html
<main id="grid">
<div id="object1">a</div>
</main>
edit: fixed (must define context even in child elements. why is that? if i can set span according to any grid amount that i want, then what's the point of all this with-layout and context following hokey pokey? If span doesn't read context from the parent element then what the hell is the point of susy?)
Here's the result

You don't have to pass the explicit context to every single container/span element if you set it globally. Susy (and any other Sass plugin) is not aware of the DOM, and so it is not aware that #object1 is inside #grid which has been set to 8 columns.
Every item needs context from somewhere. If you don't pass it in explicitly, Susy checks the global settings, which default to 4 columns. If you change the global setting to 8, then you don't need to pass context into your mixins. The with-layout mixin is just one way to change the global setting temporarily, for a block of nested code.
.default {
#include span(2); // uses global default of 4
}
$susy: layout(8);
.custom {
#include span(2); // uses global setting of 8
#include with-layout(4) {
#include span(2); // uses temporary setting of 4
}
#include span(2); // uses global setting of 8 again
}

Related

Angular 4 ngStyle sum works as string not number

<div class="scroll-element-content" [ngStyle]="{'width.px': (this.width + this.trackWidth)}">
this.width is 400 and this.trackWidth is 8
the width of .scroll-element-content will be 4008 (because sum is acting like a string)
these variables ar defined as numbers
height: number;
width: number;
trackWidth: number;
I found a solution to sum it is:
<div class="scroll-element-content" [ngStyle]="{'width.px': (this.width - (-this.trackWidth))}">
but is ugly, somebody know how to fix?
You could wrap them both in a parseInt ( num ).
However, here is what I typically do:
Declare a const obj that settles the properties, something like:
const myStyle = { width : '0px', height : '0px' };
'0px' can be any default.
Then you set ngStyle to this object. That keeps all the conditional logic and messy stuff out of your markup. You can also properly doc/annotate the object (something you can't do simply if you set it all in the markup).
When needed, you manipulate that object in your controller, resetting the width (or any style at all) when you need to update the view.
Why don't you just add them together first in the .ts file and bind that value to the width property?

Change class for a core shape

I'm trying to change class for Pager from pager to pagination as it's conflicting with bootstrap classes.
It's defined in CoreShapes.cs with
Shape.Classes.Add("pager");
I managed to add classes I need by overriding Pager.cshtml
#{
// number of page number links to show, 0 means no link, 1 means only the current page, or more accepted.
Model.Quantity = 5;
Model.Metadata.Alternates.Clear();
Model.Classes.Add("pagination pagination-sm");
Model.Metadata.Type = "Pager_Links";
}
#Display(Model)
This results in list that has class="pager pagination pagination-sm".
Is it possible for me to remove the pager class without modifying CoreShapes.cs or using javascript? Already tried without success:
Model.Classes.Clear();

How to set property type of qml signal?

I am learning qml,quick and pyqt5 and write a small test script.
In this script, I want to drop something on my UI and print the url of it.
test.qml
import QtQuick 2.3
Rectangle {
id : root
signal clicked(int x, int y)
signal filedroped(list url)
width: 800
height: 450
MouseArea {
anchors.fill: parent
onClicked: {
parent.clicked(mouseX, mouseY)
}
DropArea {
anchors.fill: parent
onDropped: {
root.filedroped(drop.urls)
}
}
}
}
The doc says:Any of the QML Basic Types aside from the enumeration type can be used as custom property types.
But I got error like this in signal filedroped:
Invalid signal parameter type: list
Also, I have tried urllist and string.
urllist failed and string works.
What's wrong with my script?
EDIT
Since I use qml with pyqt, I do not want to use the type var.
With var, I'll got a QJSValue object instead of basic type of python in my python script.
Why qml performs different with the official document? Is the document wrong?
It seems on there's indeed an error in the Qt Documentation. It is said (here) that
the allowed parameter types [for signal parameters] are the same as those listed under
Defining Property Attributes on this page.
Yet one can define a property as follow:
property list<Item> items
whereas this is invalid:
signal mysignal(list<Item> items)
But anyway, the QML list type was not a solution. The official documentation is quite clear:
A list can only store QML objects, and cannot contain any basic type
values. (To store basic types within a list, use the var type
instead.).
In other words you can't use list to store strings, url, int. You have to use var. Another solution would be to use a formatted string with a custom separator instead of your url list, and split it on the Python side.
It looks that urllist is an array of urls so you can use var in this case:
signal filedroped(var urls)

NgAttr value initially empty when containing mustache directive in AngularDart

Chapter 3 of the AngularDart tutorial defines a rating #NgComponent (see excerpt below), that is used in index.html like this:
<rating max-rating="5" rating="ctrl.selectedRecipe.rating"></rating>
In that chapter it is also suggested that that the max-rating #NgAttr can be set via a {{...}} like this:
<rating max-rating="{{ctrl.max}}" rating="ctrl.selectedRecipe.rating"></rating>
In the RecipeController I have simply declared:
int max = 5;
If I add print("maxRating('$value')") at the top of the component's maxRating() setter body (see below), then in running the app I get the following output:
maxRating('') // printed 7 times
maxRating('5') // printed 7 times
Questions: Why is the value initially empty? I assume that it is because the interpolation has not been done yet, but then why is the setter called at all before the value is "ready"?
Excerpt of RatingComponent class definition:
#NgComponent(
selector: 'rating', ...
publishAs: 'cmp'
)
class RatingComponent {
...
#NgTwoWay('rating')
int rating;
#NgAttr('max-rating')
set maxRating(String value) {
var count = value == null ? 5 : int.parse(value);
stars = new List.generate(count, (i) => i+1);
}
As far as I know, angular dart is very eager in applying values. As soon as angular is running it starts applying values, I guess to provide a feel of responsiveness.
I've been bitten by this too and had to write more than one workaround for not yet initialized values.
The setter and getters are called by the binding mechanism to stabilize the values, as some values may depend on each other and the mechanism "brute forces" this by just setting and getting values multiple times (7 by default, IIRC).

Monotouch Dialog: Styling Elements

I'm using Dialog and would like to style all my cells. I have a background image, and in the samples I can see how you can use a StyledStringElement to use that image.
However, in real use some sections use other elements. For example the last element in one section is a RootElement - but it has no BackgroundUri property to set. The same would go for boolean elements.
I found this question - What's the best way to customise all monotouch.dialog TableViewCells to the same style (Background, etc..)? which is a similar question a year and a half back. The UIAppearance styling mentioned does exist for tablecells but does not work with MTDialog. krtrego's answer to this In monotouch.dialog can RootElement be easily styled? question purports to do the job, but no styling occurred when I implemented it.
Is there now any improved way to do this? Implementing my own 'styled' versions of these other control types would be a big effort and looking at the styledstringelement this is beyond my current skill level.
Here's an example of what I'd like to achieve (the shadow below the 'tags' cell, but the element is actually a RootElement with a set of radio options beneath it). Removing the default grey lines etc is easy enough, but putting a subtle shadow on the bottom cell of each section is what I cannot work out.
Many thanks!
PS. With a normal MTDialog screen with cell backgrounds and borders removed, there is a subtle white shadow/line beneath each section as it is. If I could just recolour that I'd be a long way to where I want to be...
Subclassing the element will let you style it via overriding the GetCell method, but that gets pretty tedious. The best solution I have come across is to to make a custom DialogViewController by subclassing it, and overriding the CreateSizingSource method with your own SizingSource and GetCell() methods using the images you want for each scenario of a cell (top, middle, bottom, alone). Its a bit of code and my example wont handle uneven rows, but it is the only solution I have seen that does not modify the MT.D source code.
Here is what you would override in your DialogViewController subclass:
public override Source CreateSizingSource(bool unevenRows)
{
return new CustomSource(unevenRows);
}
Then you would make a custom source class:
public class CustomSource : Source
{
public CustomSource(DialogViewController parent) : base (parent)
{
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
var theCell = base.GetCell(tableView, indexPath);
if (RowsInSection(tableView, indexPath.Section) == 1) //use one with top and bottom rounded
{
theCell.BackgroundView = new UIImageView(Theme.CellBackgroundFull);
theCell.SelectedBackgroundView = new UIImageView(Theme.CellBackgroundFullActive);
} else if (indexPath.Row == 0) //top only
{
theCell.BackgroundView = new UIImageView(Theme.CellBackgroundTop);
theCell.SelectedBackgroundView = new UIImageView(Theme.CellBackgroundTopActive);
} else if (indexPath.Row+1 == RowsInSection(tableView, indexPath.Section)) // bottom only
{
theCell.BackgroundView = new UIImageView(Theme.CellBackgroundBottom);
theCell.SelectedBackgroundView = new UIImageView(Theme.CellBackgroundBottomActive);
} else //anything in the middle
{
theCell.BackgroundView = new UIImageView(Theme.CellBackgroundMiddle);
theCell.SelectedBackgroundView = new UIImageView(Theme.CellBackgroundMiddleActive);
}
return theCell;
}
}
Theme is just a static class that returns UIImages, similar to the example Field Service app from Xamarin. So here I have made 8 images total. 4 to represent the top, middle, bottom and alone for an element. Each has different rounded corners to appear correct. And then a "highlighted" version of each for when its touched.
The big drawback here is you have to do this for every different styled controller you would need. If you are ok with modifying the MT.D source code, you can get a different solution that will allow you to control it at the Section level here: http://fastchicken.co.nz/2012/05/20/earnest-debrief-visual-styles-in-ios-apps-uiappearence-custom-sections-in-monotouch-dialog/
Which has the same effect, but you only need to subclass Section for each different style, which makes including multiple styles in one Root easier. A pull request was made for this change, but Miguel favored the first solution instead, seen here: https://github.com/migueldeicaza/MonoTouch.Dialog/pull/180

Resources