im trying to render a a side menu with a submenu , however i soon realize that the icon api is not working:
<Menu.Item key="1" >
<HomeOutlined />
<span>Home</span>
<Link to='/' />
</Menu.Item>
This is one of the menu items , it renders correctly if i were to place the icon within the menu.item.
However when i do this :
<Menu.Item key="1" icon={<HomeOutlined/>}>
<span>Home</span>
<Link to='/' />
</Menu.Item>
The icon no longer shows. I have no issues for the first approach , however when i try to tranplant the 1st approach to a submenu :
<SubMenu key="sub1" title="Settings">
<SettingFilled />
<Menu.Item key="7" onClick={this.props.logout}>
<span>Logout</span>
</Menu.Item>
</SubMenu>
It would render the icon inside the inner dropdown instead of where its supposed to be
You can try this, the icon has to be part of the title parameter in order for the icon to be shown correctly when the menu is not expanded. :-)
<SubMenu key="sub1" title={<span><UserOutlined /><span>Settings</span></span>}>
<SettingFilled />
<Menu.Item key="7" onClick={this.props.logout}>
<span>Logout</span>
</Menu.Item>
</SubMenu>
You can do this: -
<SubMenu key="sub1" title={<span><UserOutlined /><span>Settings</span></span>}>
<SettingFilled />
<Menu.Item key="7" onClick={this.props.logout}>
<span>Logout</span>
</Menu.Item>
But there will be an issue of padding as the padding of Menu.Item is given relative to the title of the Sub-Menu and the padding is given as inline-css so you will not be able to override the css and it's a bad habit to use important. Here, you are using so if you want the content aligned than you can give padding to the Link.
Related
Can't figure out a way around this...
I have a header (H1 tag) whose value is dependent on a variable. This header also has an icon in it. The following code displays the header text, but the icon is gone. I can understand why... the th:text is replacing everything in the tag. Is there a way to keep the icon and have a dynamic header?
Here is the code:
<h1 class="ui header" th:text="${'Widget ' +widget.id}"><i class=" ui grey cog icon"></i>Default Text</h1>
If I remove the th:text="${'Widget ' +widget.id}" piece the icon comes back.
Any thoughts?
Thanks, Keith
The th:text attribute will replace everything in the body of the <h1> tag.
You can put the text in a separate <span> instead:
<h1 class="ui header"><span th:text="${'Widget ' +widget.id}"></span><i class=" ui grey cog icon"></i>Default Text</h1>
Got the problem that the softkeyboard overlaps an entry field placed at the bottom.
XAML code:
<ContentPage.Content>
<AbsoluteLayout VerticalOptions="Fill">
<ScrollView AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,0.9">
<Label Text="Heading" />
</ScrollView>
<Entry x:Name="SearchEntry" AbsoluteLayout.LayoutBounds=".5,1,1,.1" AbsoluteLayout.LayoutFlags="All" Placeholder="Suchen..." ReturnType="Done" />
</AbsoluteLayout>
</ContentPage.Content>
I installed the KeyboardOverlap! plugin via nuget. It shifts the whole page upwards till the entry is visible again. The entry is visible, but the top of the page isn't visible anymore because it's shifted up.
Another often mentioned solution is wrapping the pages's content in a ScrollView. Because I definitively need an AbsoluteLayout as root content, that's unfortunately not a solution.
I'm looking for a solution which shrinks the height of the page and don't just shifts it up when the softkeyboard appears.
Why I need this? The page is filled dynmically with search result based on the entrie's input. If there are only few result, they're not visible because of the page's upward shift. The user could think that there aren't any search results. Displaying a text like 'No search results.' above the entry would be a simple solution but is not an option here.
Using this CustomRenderer class in the iOS project instead of the KeyboardOverlap plugin did the trick.
Don't forget to customize line 14 with your concrete page classname(s) where you need the functionality. Otherwise the renderer is called for all pages in your app!
Many thanks to Jack Hua - MSFT!
<!-- my-poly -->
<template>
<content select=".useBtn">
<button id="defaultBtn">
<content select=".useBtnIcon">
Button
</content>
</button>
</content>
</template>
So if my Element gets used, the User can input a Button which will be shown instead of the defaultBtn. But if no Button is given, the defaultBtn with the Button Text will be shown. But the user also should have the Option to use the defaultBtn and to input a text or icon which will be shown in the Button.
If I use a <div class="useBtn"></div> it will be used as the Button. But <div class="useBtnIcon"> BtnText</div> does not seem to work. Is there a way to make this work?
According to the spec its not going to work.
http://www.w3.org/TR/shadow-dom/#content-insertion-points
The content element that satisfies all of the following conditions represents a content insertion point:
The root node of the content element is a shadow root
There is no other content element in the ancestors of the content element
There is no shadow element in the ancestors of the content element
With this in mind, i guess, you cant make this thing work with nestetd content elements.
This one will work. Custom Icon wins if both are applied
<polymer-element name="the-button">
<template>
<content id="contentButton" select=".useBtn">
<button id="PREFIXEDdefaultBtn">
Default Button
</button>
</content>
<button id="defaultBtnWithCustomIcon">
<!--be sure that this content element doesnt contain a default set -->
<content id="contentIcon" select=".useBtnIcon"></content>
</button>
</template>
<script>
Polymer('the-button', {
domReady: function () {
var customIcon = this.$.contentIcon;
var disNodes = customIcon.getDistributedNodes();
//Test if the content element contains distributed nodes.
if (disNodes.length !== 0) {
this.$.contentButton.remove();
} else {
// the button is customized, remove the icon
this.$.defaultBtnWithCustomIcon.remove();
}
}
});
</script>
</polymer-element>
I'm pretty sure that your inner <content> element is purged when the outer <content> element selects its content.
Can you provide a jsfiddle or plnkr or anything for this? Polymer imports so many things, it's hard to trouble-shoot an issue without building our own project ourselves.
Without having the source to trouble-shoot this, it sounds like you might need to add the attributes to allow users to change preferences within your element in the <polymer-element> tag:
<polymer-element name="my-element" attributes="defaultBtn inputBtn">
See here: https://www.polymer-project.org/docs/polymer/polymer.html#declarative-event-mapping
That should allow users to configure your custom element. Once again, without having the code to tinker with, not sure if this is going to work for your situation?
I'm trying to learn jquery mobile and have been playing around with it for the past few days and things are going alright, but I'm not so sure if I'm taking the proper approach.
I tried making a site with a similar UI as the facebook app. On the top right and left corners of the page's header are buttons that causes the page to slide out like a drawer.
The top left button will slide the page out to the right to reveal a menu, while the top right button will slide out to the left to reveal a form to fill out.
What I did was create divs outside the page and used javascript to slide out the active page, to reveal the menu or form depending on which button is pressed:
<body>
<div id="my-menu">
<ul>
<li>Menu Item 1</li>
</ul>
</div> <!-- end of my-menu -->
<div id="my-form">
<form method="post" action="form-action.php">
<!-- form elements -->
</form>
</div> <!-- end of my-form -->
<div data-role="page" id="home">
<div data-role="header">
</div>
<div data-role="content">
</div>
</div> <!-- end of home -->
</body>
I used my own CSS to style the menu, but I also noticed my theme wasn't applied to "my-form", but everything in the page "home" had all elements properly styled.
I can't put the form inside the page "home" because I will not be able to do sliding drawer effect that I've done with the menu.
Am I suppose to have my own styling applied to the form outside the page or is there a way to apply the jquery mobile theme to elements outside the page?
Would this be the best approach to implement this kind of user interface or is there a better way using what's available in jquery mobile?
Since this will be my UI for the application does that mean I will just copy the same code to all the pages? Or is there a better way to do this?
I'd like to use the best practice for this use case so please offer any advice!
Thanks in advance for the help!
BTW I did the slide menu based on this blog post:
http://blog.aldomatic.com/facebook-style-slide-out-menu-in-jquery-mobile/
Solution 1:
As I told you in comments, jQM style can not be applied outside of page container but that should not prevent you from using its css.
If you are using firefox, use firebug plugin and take a look at every jQM page element, copy its structure and css. Use it to create styling outside page container.
One more thing, new elements are going to be styled but they will not have functionality, you will need to redo it by yourself.
Solution2:
Have your content inside a data-role="page" div at page-load, let jQuery Mobile style the page, and then move your content div out of the data-role="page" div to be a child of the body tag.
There are a <p:inputText> and a <p:commandButton>. I want to click the button to open a dialog with a table. When I select one row and press OK, I would like set the value of the selected row in the <p:inputText>.
In the dialog, I use an <iframe> and call a JS function to set the src of <iframe> and show the dialog. But I have no idea to update the <p:inputText> from an <iframe>.
Main page:
<h:form id="dialogForm">
<p:inputText id="tarText" value="" />
<p:commandButton value="master file" oncomplete="showDialog('#{request.contextPath}')" />
<p:dialog widgetVar="lookupDialog" header="Lookup">
<iframe id="myiframe"></iframe>
</h:form>
JS:
function showDialog(contextPath) {
var myiframe = document.getElementById("myiframe");
myiframe.src = contextPath + "/pages/lookup.xhtml";
lookupDialog.show();
}
Edit----
#BalusC but how can I refresh a special area of this page by pressing a button? The more important thing is, the different button pressed, the different content shown out. And I don't wanna refresh the page sync.