How to span a number of columns, regardless of the nested grid context? - susy-compass

I need to set the width of an element that is used in various places in my fluid Susy layout. The parent element is not always the same width, but I want this element to always have the same width relative to the page width.
Example:
In a 12-column grid, a news article sometimes spans 12 columns, sometimes 6. Editors are able to add a <blockquote> in the news article text. I want a blockquote to always be 3 columns wide (relative to the full page), regardless of its context (12 or 6 columns).
Of course if this was a grid with fixed column widths it would be easier, but I'm looking for a fluid, percentage-based solution.
PS. I am willing to use Susy 2 alpha if that makes it easier to solve the problem.

You would do this the same way in Susy 1 or 2, though it's always more fun in 2. :)
The issue isn't really related to anything specific about Susy, it would be a problem in any fluid CSS situation. You can only solve it if you have a hook for knowing which context you are in. At that point, you can solve it from either end. Something like this:
blockquote {
#include span-columns(3);
.narrow & { #include span-columns(3,6); }
}
There really isn't any way to do it without the hook. CSS doesn't have element-queries (and isn't likely to any time soon, for the reasons given in that article).

Related

React Virtualized List - How do you use the measureAllRows method on a List?

I'm trying to render my list of data using the WindowScroller and List from react-virtualized, but for some reason, only a portion of my data is rendering. I've read over the docs and I believe I have all the necessary props...help is appreciated!
Taking my List out of the WindowScroller renders everything correctly, but I'd like to keep the WindowScroller to give scrolling controls to the parent element.
There are 100 items in my data set, but only a portion of them are rendering.
Here is a sandbox with an example: https://codesandbox.io/s/jolly-gagarin-vczki1?file=/src/App.js
UPDATE #1:
I believe I've found the cause of my error! It seems that the height in the List element is the issue; it's not large enough thus cutting off my data. Because my List has no fixed height to begin with (height depends entirely on the number of children), I think I need a way to dynamically calculate the height of the List. I did find a method for List elements called measureAllRows, but I can't get it to work :( (see my sandbox above)
UPDATE #2:
I found a really hacky way to do it; by setting the List element's height prop to Infinity, I can get all of my items to render. This doesn't feel like a good way to solve the problem, but it does fix my issue with a dynamic list height.
UPDATE #3:
The answer below helped when just using AutoSizer, but I was curious... if I were to put my AutoSizer into a WindowScroller like so: https://codesandbox.io/s/ecstatic-sunset-g4k3ly?file=/src/App.js, how could I achieve a similar fix for displaying all of my data?
I can say that the problem lies in one of the parent div for WindowScroller component which is causing this behaviour.
The overflow property cannot be set to auto for WindowScroller to work. If you try executing only the windowScroller part without modal window it works as expected.
https://codesandbox.io/s/elastic-ritchie-k938m0?file=/src/App.js
I was also stuck with similar problem and this worked for me, in your code try removing the autoheight parameter and get the height from the autosizer.
Reference:
https://codesandbox.io/s/recursing-pine-2w2m8f?file=/src/App.js

Vertical scrollbar visibility in react-virtualized table

When using react-virtualized's Table class with a table with many columns, it is necessary to scroll horizontally to the very end of the columns in order to be able to see the vertical scrollbar.
(you can see an extremely similar question about React-Table here, it is not clear to me if react-virtualized's table code uses React-Table's code at all, but in any case I am having an identical problem)
in the linked issue someone commented that:
.ReactTable .rt-tbody{
overflow: initial !important;
}
fixed their issue. I checked this solution with react-table and got the desired behavior.
However, as far as I can tell react-virtualized table doesn't have tbody class available for css. (The docs do list a bunch of available class names, but a body class name doesn't seem to be on that list).
I've messed around with the css trying to set different overflow options in different ways to no avail. I have not been able to get the vertical scrollbar to display without needing to horizontally scroll all the way to the end. What can I do to make that happen?
(Edit: I've also tried to figure out some way to make this work with react-floating-scroll but it seems like the ref passed back by virtualized table isn't the kind of ref the scroll code needs...)
This will move the scroll bar to the left side instead of right side.
.ReactVirtualized__Table {
.ReactVirtualized__Table__Grid {
direction: rtl !important;
.ReactVirtualized__Grid__innerScrollContainer {
direction: ltr !important;
}
}
}

Reference and Guidelines for Dynamic Layout using JavaFX

I am using FXML via Scene Builder to establish some JavaFX scenes and formatting templates. Having scanned the web and Oracle tutorials, I still find determining the 'rules' around how layouts size/wrap/fit-contents/etc. and spacing between elements and compoents to be 90% a black art to me. What I'm missing is the "layout overview" (missing chapter) that puts FXML (and JavaFX) layouts all together. If you've come across such a creature, please share link(s).
To date I've only found small bits of information. For example the:
JavaFX References
JavaFx JavaDocs
Java CSS Reference
Give some useful infomation on one attribute, parameter or characteristic. There seems to be nothing outlining the big picture nor making an effort to connect the dots between say "font-family" to (what are) "valid fonts"?
Also I'm looking for some examples that do more business or applications type work. More real-world(tm) examples like a data entry form that takes details with text fields, comboboxes, radio buttons, etc. Doing 'normal' on-screen things not just looking shiny graphics to show what JavaFX might do.
The main thing that I see as missing is a description relating the different JavaFX containers and elements and relating them together for formatted-appearance, formatted-layout, rendered-sizing relating to each other.
Forgive me for giving an example that sounds like a critism, it isn't intended to be I simply haven't found the information to let me satisfy some simple requirements:
Want a dynamic layout that will work on different sized displays/windows.
Some screne areas will need to size according to the content. More or less what I'd describe as, fit-to-content.
Other areas may need to be fixed width or height (as constraints).
The remaining parts of the formetted-layout would shrink or grow depending on the size and capacity of the window.
I want this in FXML: so that we can have a menu of layout styles with the same information (as views). That way we are expecting to match display with the best layout.
I can list the main, specific roadblocks I've come across (next). The thing I accept is that there are gaps in my knowldge and in what I'm reading about how containter work, how do min-prefered-max widths and heights work? How to they interact, etc.? That may be too large a question for now. I can give an example and some specifics to follow and leave it to the wisdom of the crowd ...
Example
| col-01 | col-02 | col-03 | col-04 | col-04 |
| | | | | |
| expand | fixed | scale | expand | fit |
| | percent |conetnet| | content |
| | | | | |
Specifics:
If I used a GridPane, there is NO properties or style field in SceneBuilder for the columns or rows.
Question: can I code style for GridPane rows and columns in the FXML file?
Percentages are not valid in most places (Java CSS Reference). Where can we use a percent and not use percent.
I want the columns with "expand" to grow/shrink according to the display size.
Fit content shouldn't expand (or only expand moderately).
Scale content should expand/shrink to suit the 'remaining space' and at the same time I want the content to 'fit-space' (which will normally be a graphic or other media)
What are the VALID CSS styles for elements.
What are the VALID values for the different JavaFX CCS styles?
Which style (path) selectors and combination work for JavaFX?
I still believe these constraints are do-able with JavaFX. I want the "outline rules" for my layout to be set-up in FXML. I feel that FXML should capable of doing what's needed provided I get the inforation about how to combine and set-up my layouts to satisfy the deploymed display constraints.
I'm expecting all these answers are not all in one place. As this is my second time (project) where I needed to know these things. I would prefer to get things working with a little less brute force this time because we want the flexibility offered with FXML definitions. I also think lots of us want to know how to do this but JavaFX styling is not the same as HTML. My thanks in advance.
see also:
FXML Guice, could be very useful.
Almost all of your specific questions can be answered by using the ColumnConstraints on a GridPane. Have a look at the "Work with layouts" chapter in the official tutorial.
Note that, unlike HTML (where CSS is used for both style and layout), in JavaFX CSS is not really intended to be used for layout, but just for the "look" of the application. (Clearly, there are some gray areas here, such as borders etc, but in my opinion there's a genuine difference in approach.) I think the question on percentages in CSS values becomes a moot point once you realize this difference.
For your specific example, and just off the top of my head, so this may not be exactly correct, you can do something like:
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS">
<maxWidth><Double fx:constant="POSITIVE_INFINITY" /></maxWidth>
</ColumnConstraints>
<ColumnConstraints percentWidth="20"/>
<ColumnConstraints hgrow="SOMETIMES" fillWidth="true"/>
<ColumnConstraints hgrow="ALWAYS">
<maxWidth><Double fx:constant="POSITIVE_INFINITY" /></maxWidth>
</ColumnConstraints>
<ColumnConstraints hgrow="NEVER" />
</columnConstraints>
<!-- Nodes... -->
</GridPane>
In SceneBuilder (screenshot is from 2.0, but this worked in 1.1 too), click on the "header tabs" for a column and under layout on the right you will be able to set the column constraints for that column. In this screen shot, column 1 is selected (its "header tabs" are yellow):
For your specific question 6, about css styles, I've found the CSS reference is pretty explicit about that, once you figure out how it's laid out. It lists the types and the values they take, then lists nodes, the attributes that can be used with them, and their type. The selectors are the standard css selectors, with a few pseudoclasses not being supported (documented in the introduction of the reference).
One thing that's not stated explicitly in the reference is that the "substructure" section for each Node is listing css classes. So, for example, ScrollBar (which has css class scroll-bar) has "track" listed under its substructure as a StackPane. StackPane is listed as defining a property -fx-alignment as well as inheriting all the properties of Pane, which in turn inherits all the properties of Region, such as -fx-background-color. So if I want really ugly scroll bars, I can do
.scroll-bar .track {
-fx-background-color: purple ;
}
And if I want one particular scroll bar to be ugly, I can give it a style class (say "ugly") and do
.scroll-bar.ugly .track {
-fx-background-color: purple ;
}
(So the usual selection rules for css apply.)
While the reference is pretty good, I do quite often dip into the default stylesheet source code to see how things are done there. This is a useful resource, and Oracle seem to actively encourage you to look at this. As well as the link from before, you can just extract it from the jfxrt.jar file with
jar xf JAVA_HOME/jre/lib/ext/jfxrt.jar com/sun/javafx/scene/control/skin/modena/modena.css

Orchard CMS: Add a stylesheet to a page

Setup:
I am using Orchard CMS 1.6.
I have a site where I need to be able to set the background color of the whole page. Ie, I need to style the body tag.
I could use the LayoutSelector module and have distinct layouts. However, the only difference in each layout is that the background-color rule for the body tag is different. So it seems a very un-dry way of doing things.
I can't find any way to make Vandelay.Classy add a distinct id or class to the body tag (it adds, as I understand it) an id or a class to the outer tag of a content type. In my case, that isn't the body tag.
So that is no good, I really do need to customize the body tag.
How to do this?
Note:
I need 3 different background colors. I also have a two column layout and a three column layout. [I use (a modified version of) the layoutSelector module to achieve this.] So to have 3 different colors of background, and I used layouts to achieve this, I would need 6 different layouts: TOTAL overkill.
There must be a better way...
From any cshtml file, you should be able to access the Layout shape. From pretty much anywhere else, you can still get to the Layout shape through WorkContextAccessor. Once you have a reference to the Layout shape, you can do Layout.Classes.Add("the-class-you-want").

Joomla: Create a module that spans several positions

My website at sabraso.be currently displays several modules, a bit like:
[::MODULE 1::][::MODULE 2::][::MODULE 3::][::MODULE 4::]
[::MODULE 1::][::MODULE 2::][::MODULE 3::][::MODULE 4::]
However, I want to change this layout so Module 2, which contains a landscape-format image, spans the positions 2 and 3. Afterwards, Module 3 should also be stretched to the width of Module 2 and be positioned right underneath it. Like this:
[::MODULE 1::][::::::::::MODULE 2::::::::][::MODULE 4::]
[::MODULE 1::][::::::::::MODULE 3::::::::][::MODULE 4::]
Where should I start doing this, before I actually go dig in the template files? I have noticed that some modules automatically stretch to fill the remaining space, but I cannot seem to find when and under which conditions this happens.
Now I've read one answer on Stackoverflow, but I'm not quite sure what to do with it.

Resources