SASS/Compass: Inherit from mixin - extjs

In Ext JS 4, they added a way to override the default coloring scheme by using SASS/Compass, so what I'm trying to do is create a new button style, using extjs-button-ui, and then applying that style to a button. The button's code is as follows:
xtype: 'button',
text: 'should be orange',
ui: 'orange'
My SASS code is as follows:
$button-default-background-color: mix(blue, red);
$orange-button-background-color: mix(yellow, red);
#import 'compass';
#import 'ext4/default/all';
#include extjs-button-ui(
'orange',
$button-small-border-radius,
$button-small-border-width,
$button-default-border-color,
$button-default-border-color-over,
$button-default-border-color-focus,
$button-default-border-color-pressed,
$button-default-border-color-disabled,
$button-small-padding,
$button-small-text-padding,
$orange-button-background-color,
$button-default-background-color-over,
$button-default-background-color-focus,
$button-default-background-color-pressed,
$button-default-background-color-disabled,
$button-default-background-gradient,
$button-default-background-gradient-over,
$button-default-background-gradient-focus,
$button-default-background-gradient-pressed,
$button-default-background-gradient-disabled,
$button-default-color,
$button-default-color-over,
$button-default-color-focus,
$button-default-color-pressed,
$button-default-color-disabled,
$button-small-font-size,
$button-small-font-size-over,
$button-small-font-size-focus,
$button-small-font-size-pressed,
$button-small-font-size-disabled,
$button-small-font-weight,
$button-small-font-weight-over,
$button-small-font-weight-focus,
$button-small-font-weight-pressed,
$button-small-font-weight-disabled,
$button-small-font-family,
$button-small-font-family-over,
$button-small-font-family-focus,
$button-small-font-family-pressed,
$button-small-font-family-disabled,
$button-small-icon-size
);
I have a couple of questions/observations. When I compile this, I get no errors and the standard Ext JS theme with purple buttons, but the button I defined above, has no style... it's just text. These variables are all included in the _all.scss file, which imports the _variables.scss file, which includes the variable definitions that are in variables/_button.scss, and if the vars were undefined, the compiler would whine.
My first question is, why is this not working/what am I missing?
And my second, more broad SASS question, how do I inherit from a mixin? The orange include is actually inheriting all of those variables from the default-small extjs-button-ui. So I want the background-color and name to be orange, but I want everything else to be inherited from the default-small include. Is this possible? I thought something like:
#include extjs-button-ui(
#include extjs-button-ui('default-small'),
'orange',
$button-default-background-color: mix(yellow, red)
}
would be the ticket, but I was apparently horribly wrong. I can inherit a mixin by doing something like:
.orange {
#include extjs-button-ui('default-small', $icon-size: 16px);
$button-default-background-color: mix(yellow, red);
}
But that's not creating an orange ui that I can use in Ext JS... just an orange CSS class that has the button values, but not my background-color. So what am I doing wrong? I've tried looking all over for ways to accomplish this, but nothing's working. Does anyone have any insight?

Related

Adding superscript to Draftail in Wagtail 2.0

I'm trying to add superscript to the new editor in Wagtail.
I see the documentation here: http://docs.wagtail.io/en/v2.0/advanced_topics/customisation/extending_draftail.html
Where am I supposed to add the example code?
And am I correct in assuming that I will be able to just change the example from feature_name = 'strikethrough' and type_ = 'STRIKETHROUGH' to superscript and it will work?
Once this is registered, do I have to modify each RichTextField that I have to include it in the features setting, or is there a way to add this to all RTF in my application?
I believe I have figured out how to do this, hopefully, someone will correct me if there is a better way!
Create a file in one of your registered (in INSTALLED_APPS) app directories called wagtail_hooks.py.
Put the following code in the file:
import wagtail.admin.rich_text.editors.draftail.features as draftail_features
from wagtail.admin.rich_text.converters.html_to_contentstate import InlineStyleElementHandler
from wagtail.core import hooks
#hooks.register('register_rich_text_features')
def register_strikethrough_feature(features):
feature_name = 'superscript'
type_ = 'SUPERSCRIPT'
tag = 'sup'
control = {
'type': type_,
'label': '^',
'description': 'Superscript',
}
features.register_editor_plugin(
'draftail', feature_name, draftail_features.InlineStyleFeature(control)
)
db_conversion = {
'from_database_format': {tag: InlineStyleElementHandler(type_)},
'to_database_format': {'style_map': {type_: tag}},
}
features.default_features.append(feature_name)
features.register_converter_rule('contentstate', feature_name, db_conversion)
The line features.default_features.append(feature_name) is what answers the last part of my question - and is missing from the docs (well, it's there, but not in this context). This adds the feature to all RichTextFields without having to add the features=[] setting to each existing and/or new RTF.
To modify this to work with another built in Draftail feature, modify the feature_name, type_, tag, label, and description fields. Draftail supports the following types:
Block types: H1, H2, H3, H4, H5, H6, Blockquote, Code, UL, OL, P
Inline styles: Bold, Italic, Underline, Code, Strikethrough, Mark, Keyboard, Superscript, Subscript
And HR, BR
With bold, italic, h2, h3, h4, ul, ol, hr, and br already being in the Wagtail default set for a RichTextField.
As of Wagtail v2.5, superscript is a built-in format, disabled by default. To use it, all that's needed is to enable it. Either per-field, in the model definition:
# [...]
body = RichTextField(features=['superscript'])
# [...]
Or for all editors on a site:
from wagtail.core import hooks
#hooks.register('register_rich_text_features')
def enable_superscript_feature(features):
features.default_features.append('superscript')
Note that currently, while superscript will work as expected in the editor, it won’t be possible to copy-paste content with superscript from third-party sources (Google Docs, Word, web pages) and have the superscript formatting be preserved.

Pug 2 - Pushing Array in Loop

I'm creating a document that will help me reduce time down when creating templates. I'm wanting to loop around a block of code in a seperate file with an array that I've specified in the header of the main file but can't seem to get it to work
./src/pug/layout.pug
- const flyouts = []
- flyouts.push({variationid: "123", plugin: "none", zone: "ZoneHere", variation: "LargeImage", link: "www.bbc.co.uk", imgloc: "blah.jpg"});
- flyouts.push({variationid: "456", plugin: "none", zone: "ZoneHere", variation: "LargeImage", link: "www.bbc.co.uk", imgloc: "blah.jpg"});
Calling the Loop here, in the same file
html
head
title Hello asd
body
section
// Flyouts
each myFlyout in flyouts
include components/flyouts
Which calls this block of code in ./src/pug/components/flyouts.pug
.section(variationid=variationid plugin=plugin zone=zone variation=variation)
a(href='asd')
img(src='http' alt="Event" width="206" height="148" border="0")
Anybody able to shine a light on this one?
Jade/Pug keeps the variable scope of the parent template, while including a template. Variable you are looking for here is myFlyout, which is an object with other values - variationid, plugin, etc.
You need to use myFlyout to get values within flyouts.pug. This should work -
.section(variationid=myFlyout.variationid plugin=myFlyout.plugin zone=myFlyout.zone variation=myFlyout.variation)
a(href='asd')
img(src='http' alt="Event" width="206" height="148" border="0")

unable to create ExtJS5 panel UI

I am trying to create a panel with different color header than the regular one. Since there are going to be panels with different header colors, I decided to create different uis for each of them. Here is a sample code for one of them:
#include extjs-panel-ui(
$ui: 'darkgreen',
$ui-border-color: $panel-light-border-color,
$ui-body-border-color: $panel-light-body-border-color,
$ui-header-border-color: $panel-light-header-border-color,
$ui-header-font-family: $panel-light-header-font-family,
$ui-header-font-size: $panel-light-header-font-size,
$ui-header-font-weight: $panel-light-header-font-weight,
$ui-header-color: $panel-light-header-color,
$ui-header-background-color: #666,
$ui-header-text-transform: $panel-light-header-text-transform,
$ui-tool-background-image: $panel-light-tool-background-image
);
after creating it and building my application I included a panel with ui: 'darkgreen' but there is no effect. On the contrary the panel has no css applied. Can someone point out where is the issue?
When your component has framed: true (which is the case of the panel) you should create your UI as -framed.
Try the code below:
* Just a quick note, you should change the name of your UI, but in the panel declare ui: 'darkgreen'
#include extjs-panel-ui(
$ui:"darkgreen-framed",
$ui-border-color: $panel-frame-border-color,
$ui-border-radius: $panel-frame-border-radius,
$ui-border-width: $panel-frame-border-width,
$ui-padding: $panel-frame-padding,
$ui-header-color: #FFF,
$ui-header-font-family: $panel-header-font-family,
$ui-header-font-size: $panel-header-font-size,
$ui-header-font-weight: $panel-header-font-weight,
$ui-header-line-height: $panel-header-line-height,
$ui-header-border-color: $panel-frame-border-color,
$ui-header-border-width: $panel-frame-header-border-width,
$ui-header-border-style: $panel-header-border-style,
$ui-header-background-color: #666,
$ui-header-background-gradient: $panel-header-background-gradient,
$ui-header-inner-border-color: $panel-frame-header-inner-border-color,
$ui-header-inner-border-width: $panel-frame-header-inner-border-width,
$ui-header-text-padding: $panel-header-text-padding,
$ui-header-text-margin: $panel-header-text-margin,
$ui-header-text-transform: $panel-header-text-transform,
$ui-header-padding: $panel-frame-header-padding,
$ui-header-icon-width: $panel-header-icon-width,
$ui-header-icon-height: $panel-header-icon-height,
$ui-header-icon-spacing: $panel-header-icon-spacing,
$ui-header-icon-background-position: $panel-header-icon-background-position,
$ui-header-glyph-color: $panel-header-glyph-color,
$ui-header-glyph-opacity: $panel-header-glyph-opacity,
$ui-header-noborder-adjust: $panel-header-noborder-adjust,
$ui-tool-spacing: $panel-tool-spacing,
$ui-tool-background-image: $panel-tool-background-image,
$ui-body-color: $panel-body-color,
$ui-body-border-color: $panel-body-border-color,
$ui-body-border-width: $panel-frame-body-border-width,
$ui-body-border-style: $panel-body-border-style,
$ui-body-background-color: $panel-frame-background-color,
$ui-body-font-size: $panel-body-font-size,
$ui-body-font-weight: $panel-body-font-weight,
$ui-body-font-family: $panel-body-font-family,
$ui-background-stretch-top: $panel-background-stretch-top,
$ui-background-stretch-bottom: $panel-background-stretch-bottom,
$ui-background-stretch-right: $panel-background-stretch-right,
$ui-background-stretch-left: $panel-background-stretch-left,
$ui-include-border-management-rules: $panel-include-border-management-rules,
$ui-wrap-border-color: null,
$ui-wrap-border-width: null,
$ui-ignore-frame-padding: $panel-ignore-frame-padding
);
I've done this, and it worked for me

Mixing id- and class-selectors in CSS with JavaFX 8

Is there a way to make class- and id-selectors work together in JavaFX 8?
E.g.: I´d like to style a progressbar the following way:
.myprogressbar #greenBar .bar {
-fx-background-color: green;
}
This solution used to work before JavaFX 8.
Your css selector is matching a Node with class "bar" which is a descendant of a Node with id "greenBar" which in turn is a descendant of a Node with class "myprogressbar".
I assume you're setting the class "myprogressbar" and the id "greenBar" on the same node (a ProgressBar). To match this, you need to remove the space between .myprogressbar and #greenBar:
.myprogressbar#greenBar .bar {
-fx-background-color: green;
}
If you want to set a css style by id but just for a part of a node, the following code snippet did the trick for me:
In my css stylesheet file I defined this:
#agile-board *.split-pane-divider {
-fx-background-color: #C9C9C9;
-fx-border-style: dashed;
-fx-border-width: 1px;
}
In my class where I wanted to use this style I did this:
this.board = new SplitPane();
this.board.setId("agile-board");
The node got the style wit the id #agile-board applied but just the divider of that SplitPane.
Good programming :-)

How to display an ExtJS window with a different colour

I need to display a window Ext.Window with a colour different to that of the default theme.
Changing the colour of the guts of the window is easy enough. Changing the colour of the chrome of all popup windows is also very easy. Changing the chrome of a single window seems extremely hard. Best as I can tell, you need to copy all the styles (x-window and similar), rename and customise them and set the baseCls of the window.
Is there an easier way to do this?
In configs for the window ...
bodyCls: 'popWindow',
and then somewhere in a css
.popWindow
{
background-color: blue;
}
You can add your own custom class to the window, then write CSS rules for that class.
Check out the cls config option or the addCls method on Ext.Window. Try it out, then inspect the class applied to your window to figure out where to apply your CSS rules.
Here's the doc for Ext.Window. In Ext 3.x, I believe the method is addClass. But the config option was still cls (I think).
Sorry to answer my own question, but I finally worked out a way to colour a single window in isolation of other windows. Initially I thought I was going to have to clone the entire x-window set of classes and modify the clone but I have since found an easier way to do it.
I got a lot of help from this link but also used a lot of trial an error as my CSS skills suck
You'll need to clone and edit the background images used by
the overriding css. The files you'll need are top-bottom.png, left-right.png, left-corners.png, right-corners.png and tool-sprites.gif
The window that you wish to colour needs to have an id ('defn_display' in this
example).
Set the bodyCls of the window to a separate class that sets the background colour. For example:
.defn_content
{
background: #FFFFDD !important;
}
You need to set up the css class selectors to override the
x-window classes based upon this id using the new images cloned in step 1.
#defn_display * .x-window-tc {
background-image: url("/static/images/defn-top-bottom.png");
}
#defn_display * .x-window-ml {
background-image: url("/static/images/defn-left-right.png");
}
#defn_display * .x-window-mr {
background-image: url("/static/images/defn-left-right.png");
}
#defn_display * .x-window-tl {
background-image: url("/static/images/defn-left-corners.png");
}
#defn_display .x-window-tl {
background-image: url("/static/images/defn-left-corners.png");
}
#defn_display * .x-window-bl {
background-image: url("/static/images/defn-left-corners.png");
}
#defn_display * .x-window-tr {
background-image: url("/static/images/defn-right-corners.png");
}
#defn_display * .x-window-br {
background-image: url("/static/images/defn-right-corners.png");
}
#defn_display * .x-window-bc {
background-image: url("/static/images/defn-top-bottom.png");
}
#defn_display .x-tool {
background-image: url("/static/images/defn-tool-sprites.gif");
}
#defn_display * .x-window-header-text {
color: #515111;
}
The CSS seems to do the trick with one exception: the drag ghost is tricky to override since it is not a child of the window. As such, I still get a blue ghost during dragging.
(Tested under FF, Chrome and IE6 with ExtJs 3.4)
Check the ui property. I never tried it by myself, but I heard on Sencha conference that it's possible. Good luck...

Resources