I have several MXML layouts that are used for my application's menu on the Playbook, I need to be able to create a different layout for each orientation because my side-bar menu wouldn't work when in portrait, what is the best way to create a view or two that can be used in each orientation but share the important functional code.
I tried first to make MXML views and separate the script and into a file and including it with the script tag but this doesn't work well for various reason.
An alternative more suited to the proper use of the flex tools and capabilities would be appreciated.
Thanks
For that you use States in one MXML, for example:
<s:View>
<s:states>
<s:State name="portrait"/>
<s:State name="landscape"/>
</s:states>
<s:layout.portrait>
<s:HorizontalLayout/>
</s:layout.portrait>
<s:layout.portrait>
<s:VerticalLayout/>
</s:layout.portrait>
<s:Label includeIn="portrait"/>
[...]
</s:View>
Related
I'm trying to use a next/image instead of a regular img tag in the code below. With the regular <img> tag, the following achieves exactly what I'm looking for:
<div>
<picture>
<source
srcSet="https://via.placeholder.com/100/333333/ffffff.png"
media="(prefers-color-scheme: dark)"
/>
<img
src='https://via.placeholder.com/100/dddddd/000000.png'
width='100px'
height='100px'
alt='Placeholder image'
/>
</picture>
<p>Change your OS or browser's preferred color scheme to see a different image.</p>
</div>
Indeed, when I set my OS (or browser) to the dark theme, I get a dark image, and vice-versa for the light theme.
However, if I try the same thing with a next/image, I just get the light-themed image every time… I can't put this into a snippet because next/image requires a Next.js server, but here is the code that I'm using, which, in my tests, is backed by a Next.js development server with the appropriate image-related settings configured in next.config.js:
// pages/test.js
import Image from 'next/image'
export default function MyWebPage () {
return (
<div>
<picture>
<source
srcSet="https://via.placeholder.com/100/333333/ffffff.png"
media="(prefers-color-scheme: dark)"
/>
<Image src='https://via.placeholder.com/100/dddddd/000000.png' width='100px' height='100px' alt='Placeholder image' />
</picture>
<p>You can change your OS or browser's preferred color scheme, but you'll always see the light-theme image.</p>
</div>
)
}
Here I never get the dark-themed image, unfortunately.
Theories:
Perhaps next/image doesn't interact with the <picture> tag exactly the same way as <img>? But I'm not finding anything online about using next/image with the <picture> tag…
Perhaps I should be providing this media-query-dependant source set in a different way when using next/image? But, I'm not finding any media attribute in the next/image docs…
Question:
How can I change the src of my next/image based on the user's preferred color scheme?
Non-solutions:
I could put 2 images on the page and use display: none on one of the two as a function of the user's preferred color scheme, but I'm hoping to find a solution that doesn't require so many duplicate images all over the place, which incurs a (small) performance penalty and makes the code that much harder to maintain, or that much more complex if a helper component is created.
I could change the src using Javascript when the page loads, but this would result in a flash of incorrectly styled content and generally does against my objective of having my page fully server-rendered and compatible with browsers where Javascript is turned off.
I could use cookies to let the server know about a user's color scheme preference and render the page consequently, but this would not work for the very first visit and comes with the requirement to include a cookie bar to inform the user of the reasons behind the use of cookies, as well as a way to opt-out.
Is there a way to make a TelerikChart which nested inside TileLayoutItem to be 100% width of the Content?
Following isn't working, (the chart is being cut at the right end)
<TileLayoutItem ColSpan="2" RowSpan="2">
<Content>
<TelerikChart Width="100%" Height="100%">
<ChartSeriesItems>
<ChartSeries Type="ChartSeriesType.Line" Name="Completed" Data="#_clientDuration">
</ChartSeries>
</ChartSeriesItems>
<ChartValueAxes>
<ChartValueAxis Color="red"></ChartValueAxis>
</ChartValueAxes>
<ChartCategoryAxes>
<ChartCategoryAxis Categories="#_xAxisItems"></ChartCategoryAxis>
</ChartCategoryAxes>
</TelerikChart>
</Content>
</TileLayoutItem>
It should work like that unless some more CSS from the web site is breaking things. Also, when the tiles resize you may want to .Refresh() the chart.
The provided snippet runs fine for me when I run it in the boilerplate project template and I add some dummy data, and the same scenario runs in this demo as well.
Thus, the issue is probably related to something specific in the project and if comparing against the demo or a blank project does not help I think the better approach is to contact the Telerik support.
I'm working on a SAPUI5 application with XML-Views.
Now I want to arrange my buttons for example. They should be arranged so they form a numberpad like on a keyboard.
I only know the layout managers from Java or the layouts of a SAP Web Dynpro where I also used transparent containers.
So how can I arrange my elements in HTML? How can I use layout managers and is there such a thing as a transparent container?
Thanks for any hints! :)
Arranging HTML elements in SAPUI5 is how you would in normal HTML. SAP does emphasize that code in index.html is to be minimal, however, so do your best to keep your coding done inside of your views. Your elements are likely to be contained in <div>, </div> tags, which, like any other HTML tag, can be manipulated using CSS.
You'll need to create a CSS file and reference it in your index.html file like so:
<link rel="stylesheet" type="text/css" href="css/style.css" />.
Additionally, you should be aware of the native SAPUI5 layout controls and use them when you can as opposed to writing up your own solution.
You might find this post useful as well.
I'd like to adapt my CKEditor so that when editing an image or other object it will show something like this in the editor view
<figure style="float: left">
<img src="sample.jpg" />
<figcaption>Caption</figcaption>
</figure>
On save it should transform this part to something else, for example
<node id=3 />
Does the CKEditor have any support for this, maybe through Widget, dataProcessor, or otherwise?
The short answer - yes, this can be done using the CKEDITOR.dataProcessor.
First thing to notice is that if you would use the widgets system (you will be interested in the image2 plugin), then you would be able to use downcasting to transform captioned images into whatever you want. Similar thing is done in Drupal 8, because Drupal saves captioned images as <img src=".." data-caption=".." ..>. (Note: Drupal 8 uses the image2 plugin but it overrides some things like e.g. downcasting method.)
The relation between mentioned CKEDITOR.dataProcessor and the widgets system is that the widget system uses the data processor to perform upcasting and downcasting of the widgets. Upcasting means discovering elements that should be turn into widgets and performing necessary transformations on the loaded data. Downcasting is the opposite.
You can also use the data processor without using widgets. You can do that:
either by using the filter.addRules() method on the editor.dataProcessor.htmlFilter and editor.dataProcessor.dataFilter filters,
or by hooking into the data processing on higher level using the editor.toDataFormat and editor.toHtml events.
What's the easiest way to set the font sizes for ALL telerik control to a single value? I believe you can control fonts by modifying the CC of a specific control, but that's a pain because I am using many different control types...
I don't know of any way to set the font size of all different telerik controls at once, but what you can do is create a theme and a skin file, where you can set the font size for each telerik control.
E.g. create a file app_themes/my_theme/telerik.skin and add a skin definition for each control to it:
<telerik:RadGrid runat="server" Font-Size="12px" />
<telerik:RadComboBox runat="server" Font-Size="12px" />
and so on...
You are most likely using one of the default skins.
You will have to go into the Skins directory of every different type of Telerik control you are using and adjust the font size in the Styles.css file.
<telerik:RadGrid ID="RadGrid1" runat="server" Font-Size="Smaller"></telerik:RadGrid>
or use style builder or generate new skin or modify existing.