How to style Button with Apache Royale - button

Playing with exemples located in apache-royale-0.9.6-bin-js\royale-asjs\examples, I tried to change background or font color of a Button.
So, I found an exemple of how to use style for js|TextButton, but I ask myselft several questions :
1) how to do same thing with j|Button ?
2) how to do if I want to change the color of j|Button on a clic (search for a 'setStyle' equivalent)
Here is full code :
<js:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:js="library://ns.apache.org/royale/basic"
xmlns:j="library://ns.apache.org/royale/jewel" >
<fx:Style>
#namespace j "library://ns.apache.org/royale/jewel";
#namespace js "library://ns.apache.org/royale/basic";
j|Button {
color : #ffA3EE ; /*Has no effect, not sure I do the right things*/
}
js|TextButton {
background-color: #fc0000;
border-radius : 6px ;
font-weight : normal ;
line-height : 1.4 ;
color : #ffA3EE ;
font-size : 15px ;
padding : 5px ;
}
js|TextButton:hover {
background-color: #CFCFCF;
vertical-align: middle;
border: none;
border-radius: 6px;
}
js|TextButton:active {
background-color: #77CEFF;
color: #FFFFFF;
}
</fx:Style>
<fx:Script>
<![CDATA[
private function ev_clic_jbutton():void{
//jbutton.setStyle("color",0x00ff00); // How to do to change color ?
}
]]>
</fx:Script>
<js:valuesImpl>
<js:SimpleCSSValuesImpl />
</js:valuesImpl>
<js:beads>
<js:ApplicationDataBinding />
</js:beads>
<js:initialView>
<js:View width="100" height="100" >
<j:HGroup gap="10">
<j:Button id="jbutton" click="ev_clic_jbutton()" text="J Button" width="100" height="100"/>
<js:TextButton text="JS TextButton" width="100" height="100"/>
</j:HGroup>
</js:View>
</js:initialView>
</js:Application>
Regards

In the case of Jewel, styles are modified via CSS. Selectors uses the following format: .jewel.<component-name>. In the case of Jewel Button, use the following to affect all jewel buttons at once and change color of text label to red:
<fx:Style>
.jewel.button
{
color: #ff0000;
}
</fx:Style>
(You can add this selector in an external CSS file too if you want instead in MXML or AS3)
The compiler will output this selector rule instead of the one in the Jewel Theme since your project takes precedence.
For change only one instance:
.jewel.button.mystyle
{
color: #00ff00;
}
and use it:
<j:Button text="A Button" className="mystyle"/>
The previous button will change color of text label to green.
Additionally, you can use j|Button as you did to change or add beads at runtime (IBead)
In the case of Basic components all is done through js|Button, beads, and CSS styles.

Related

How to set style for title inside PageHeader?

<PageHeader className="site-page-header" title={title} subTitle={subTitle} {...(onBackClick !== undefined ? {onBack: () => { onBackClick() } } : {})} />
And
.site-page-header {
border: 1px solid rgb(235, 237, 240);
background-color: #253655;
}
How can I set the color of title (or any text) in this element to another color (from default black)? I tried to set every color related field I could find in .site-page-header but nothing seems to work.
Inspecting the elements to see why the color prop is not passed down to the title reveals that the class .ant-page-header-heading-title has a color prop which has higher specificity. Either add the !important to the color or increase specificity e.g.
.site-page-header .ant-page-header-heading-title {
color: blue;
}

React jsx conditional styling of <input/> component

I am conditionally styling my <input/> (standard HTML) component. I am passing inline JSX style as a style prop:
render() {
return (
<>
<input
type="text"
style={{
width: "100%",
paddingLeft: "8px",
paddingTop: "6px",
paddingBottom: "6px",
border: this.state.error
? "2px solid red"
: this.state.value
? "2px solid #2684ff"
: "2px solid hsl(0, 0%, 80%)",
outline: "0px",
"&:hover": {
border: "2px solid green"
}
}}
placeholder={this.props.placeholder}
onChange={this.handleInput}
onFocus={this.checkErrors}
value={this.state.value}
onBlur={this.sendData}
/>
{this.state.error ? (
<div className="errorMsg"> {this.props.errorMsg} </div>
) : null}
</>
);
}
My conditional styles work, and <input/> border colour changes based on this.state.error and this.state.value, however I can't get '&:hover' style to work. I have checked my .css and there is nothing overriding the style passed as props.
I have tried another approach, where I conditionally set className for my <input/> and define style in external .css file. It works and I can change border colour with:
input[type="text"]:hover {
border: 2px solid pink;
}
However, I would like to make this work in inline JSX. Why does my style for '&:hover': { ... } not work?
The "&" operator mean the current selector in preprocessing language like sass:
input {
&:hover {
background: red;
}
}
Will compile to:
input:hover {
background: red;
}
But you will have to use sass or styled component to use that sync tax.
Pseudo css selectors don't work in inline style.btw I would not recommend any of the js solution in the comments above .you need a more a robust css solution to handle all kind of pseudo selectors.
Your options are:
Use css in js solution like styled-components.https://styled-components.com/
Use regular css or scss and condionaly switch classNames.You
can utilize classnames library for easier experience.https://www.npmjs.com/package/classnames
Render style tag above your input and put your input styles there.quite bad practice and ugly.

Using CSS to style my Flex application

I'm using flash builder 4.5 to make a website. At the moment I'm trying to work on the layout of my website but I'm facing some problems. First of all my CSS looks like this.
/* CSS file */
#namespace s "library://ns.adobe.com/flex/spark";
#namespace mx "library://ns.adobe.com/flex/mx";
s|Application{
backgroundColor : #ffffff;
}
mx|LinkButton{
backgroundColor : #000000;
color: #666666;
}
s|Button{
backgroundColor : #666666;
color: #666666;
}
The problem is that neither my buttons nor my linkbuttons obtain the color I have set in the above stylesheet, yet my application backgroundcolor is the color i set it to be in the above css file. So I'm sure the url for my style sheet is correct... this is it:
<fx:Style source="PsyThOn.css"/>
This is what my code looks like(a fragment)
<mx:LinkButton id="btnHome" width="100" height="30"
label="Startpagina" click="goHome(event)"/>
<mx:LinkButton id="btnProfiel" visible="{profielVisible()}" height="30"
label="Profiel" click="toonProfiel(event)"/>
Since I'm relatively new to the flex development the problem might be obvious but i can't put my finger on it.
Any help?
Is there maybe another/better way to style a flex application?
Thanks in advance.
try using chromeColor
Like this:
s|ActionBar
{
chromeColor: #229988;
titleAlign: center;
}
s|ActionBar #titleDisplay
{
color: #CCCCCC; /* default color is white */
fontSize: 40;
fontFamily: "Comic Sans MS";
}

Flex AreaChart CSS: Can style area fills but not area strokes and alpha?

I'm working on this AreaChart. But how come I can set area fills through CSS but not area strokes and alpha? That makes no sense!
<fx:Style>
#namespace mx "library://ns.adobe.com/flex/mx";
mx|AreaChart { chartSeriesStyles: Series1, Series2; }
.Series1 { areaFill: #999999; areaStroke: #666666; alpha: 0.8; }
.Series2 { areaFill: #cccccc; areaStroke: #999999; alpha: 0.8; }
</fx:Style>
It only works when I take out the areaStrokes and alphas.
I got the alphas working by doing:
<mx:AreaSeries ... alpha="0.8" />
But the same does not work for areaStrokes:
<mx:AreaSeries ... areaStrokes="#999999" />
What should I do?
Mats
AreaStrokes and fills aren't just simple colors, but objects: SolidColor and Stroke. You'll have to check this to see how to set them:
http://livedocs.adobe.com/flex/3/html/help.html?content=charts_types_02.html
You'll probably have to set them in the MXML.
<mx:AreaChart ...>
<mx:areaStroke>
<mx:Stroke color="0xff0000" weight="2"/>
</mx:areaStroke>
<mx:areaFill>
<mx:SolidColor color="0xffff00" alpha="0.8"/>
</mx:areaFill>
</mx:AreaChart>

Styling buttons of Flex TabNavigator

I created a TabNavigator with a bunch of NavigatorContent inside it, and want to skin just the buttons of the tabs themselves. So I added a skinClass, but looks like in the documentation, there's no skin part to target the button specifically.
Do I have to style the mx:TabNavigator itself to accomplish this? I was hoping not since I don't know how to style mx components and am more comfortable with styling spark.
Any other alternatives that I didn't think about?
Since TabNavigator is a mx component, you'll have to style it the old way. You can style the buttons by setting the 'tabStyleName' style, ie:
TabNavigator{
tabStyleName: "myTabButton";
}
.myTabButton{
skin: ClassReference("com.yournamespace.skins.TabButtonSkin");
}
You'll have to create the skins the old way, you may want to look at the mx.skins.halo.Button class for an example, or you can use degrafa or you can use pngs.
Note you can also set a firstTabStyleName or lastTabStyleName seperately if you so desire.
programmatic skin example:
http://www.davidflatley.com/2007/12/17/programmatic-button-skins-in-flex-3/
degrafa example:
http://styleanderror.net/2010/02/creating-animated-programmatic-button-skins-in-degrafa/
You can write you own button skin or use the one here http://www.wabysabi.com/flex/enhancedbuttonskin/
named EnhancedButtonSkin.as (right-click, View-Source).
Then declare your TabNavigator component and specify its tabStyleName.
<mx:TabNavigator y="0" height="100%" right="0" left="0" id="navigator" tabStyleName="tab">
And now the css:
<fx:Style>
.tab
{
upSkin:ClassReference('com.EnhancedButtonSkin');
overSkin:ClassReference('com.EnhancedButtonSkin');
downSkin:ClassReference('com.EnhancedButtonSkin');
disabledSkin:ClassReference('com.EnhancedButtonSkin');
selectedUpSkin:ClassReference('com.EnhancedButtonSkin');
selectedOverSkin:ClassReference('com.EnhancedButtonSkin');
selectedDownSkin:ClassReference('com.EnhancedButtonSkin');
selectedDisabledSkin:ClassReference('com.EnhancedButtonSkin');
cornerRadii: 5, 5, 0, 0;
borderColors: #CC0000, #000000;
overBorderColors: #003399, #003399;
selectedBorderColors: #666666, #FFFFFF;
borderThickness: 1;
borderAlpha: 1;
fillColors: #CC3300, #F98900;
fillAlphas: 1, 1;
fillColorRatios: 0, 255;
overFillColors: #999999, #FFFFFF;
overFillAlphas: 1, 1;
overFillColorRatios: 0, 255;
selectedFillColors: #999999, #FFFFFF;
selectedFillAlphas: 1, 1;
selectedFillColorRatios: 111, 255;
highlightAlphas: 0, 0;
color: #000000;
textRollOverColor: #000000;
fontSize: 13;
}
</fx:Style>
This css will display:
i.imgur.com/4HwD3.png
Remy

Resources