Conditionally trigger Button navigation in Material UI 1.0 - material-ui

Material UI 1.0 (1.0.0-beta.41, specifically) provides a nice API for using buttons to trigger navigations:
import { Link } from 'react-router-dom'
import Button from 'material-ui/Button';
<Button component={Link} to="/open-collective">
Link
</Button>
Source
My question: Is there a way to trigger the navigation, only after some other conditions are true? E.g. upon clicking the button, I do some form validation. Only if the form is complete should the button route to another page.

Related

I am trying to make side menu in ionic app. But links of side menu not clicking

I am trying to make a side menu bar in my app. the side menu is showing. but I can't click those links. When I inspect the page and select an item, it is selected tag.
Assuming that you have used this example. This example does not implement click events, to add them:
In React, use onClick() handler.
In Angular, use ng-click or bind event (click)
This should be added to every "ion-item" tag in above example.

Show search history in ionic

So I want to create a modal-like behavior for the search.
When the ion-searchbar is focused, a modal would slide from the bottom showing search history, which would hold the suggestion once the user starts typing. The problem with ionic nodals is the backdrop, I couldn't keep the ion-searchbar active to input search words.
This component is called Popover, you can create them pretty much like you do with a modal but using an PopoverController instead. The PopoverController.create() method has an event parameter that will tell which element will be the anchor for the popover, set that to your search bar and it should be magically aligned.
By default a backdrop is shown when the popover is created but it can be deactivated via showBackdrop property upon creation.
Take a look at the Ionic's Popover API Docs for further information
I ended up by using segments, as below:
<div *ngIf="segment == 'prodSection'">
...
</div>
<div *ngIf="segment == 'searchSection'">
...
</div>
I styled the two divs in a way to be on top of each other and added events to the searchbar like:
<ion-searchbar (ionFocus)="openSearch()" (ionCancel)="retProd()"></ion-searchbar>
And toggeled between the segments with setting the segment variable's value with each event.

Ionic navigation with starting dashboard and side menu

I have a simple app which always starts up a dashboard. This is the initial page where the user has an overview over the current state.
From there he navigates to modules using direct links on the dashboard itself or the given side menu.
In every module there should be a back-button visible to reach the dashboard. Whenever the user navigates from Module A to Module B (using the side-menu, which is always available!) the back-button should not navigate back to Module A, it should target the dashboard...
Here a sketch how it should be:
Red: Expected back navigation from view
Blue: Possible navigation on
screen
Blue (dotted): Possible Navigation using the side menu
Is there any way to archive this?
Yes it's possible. The easiest way to achieve this is to just forget (disable) the Ionic default back button and place one of your own in there. Have a abstract controller for the whole app or make your own for the header or where ever you would like the back button to be (a place where to place the controller code). For example:
HTML:
<button class="button button-clear header-item" ng-click="goToDashboard()">
<i class="icon ion-android-arrow-back"></i>
</button>
Controller:
$scope.goToDashboard = function() {
$state.go('dashboard');
};
Here is a simple Codepen about the solution: https://codepen.io/thepio/pen/GqvvjA?editors=1010
In this example you can just navigate to different tabs through the content and then navigate back to dashboard with the arrow on the left top corner.

How to make a button perform a Facebook like action?

I know that Facebook provides some code to add one of their like buttons to webpages, but what I need to do is create a custom button which does the same thing. So for example:
<input type="button" value="Like" id="fb-like"/>
I would like that button to send an action to like the website because I can apply custom styling to it which looks a lot better than FB's own bright blue buttons.
Is this possible? I can't find the code to make a custom like button work.

Calling Facebook login button from appbar

I implemented Facebook login button following the facebook SDK info, and it is working nicely.
<StackPanel Orientation="Horizontal" Margin="12,2,0,0" Height="70" width="430">
<fbc:LoginButton x:Name="loginButton" Width="200" applicationId="xxxxxxxxxxxxxxx" SessionStateChanged="OnSessionStateChanged"/>
</StackPanel>
However. I'd like to hide the blue button from the main view area and move it to the appbar. Can this be done somehow? My initial idea was to dig up the call login button makes when you click it and make this call from appbar button, but I can't find any info about the inner working of the login button.
Yes, you can "in a way" implement it. The underlying concept is calling an event from another event. You need to carry out the following steps.
1.Set up the AppBar.
2.Give the AppBar button a unique suitable icon.
3.Call the Facebook Login Button's click event through the AppBar Button's click event.
void appBarButton1_Click(object sender, EventArgs e)
{
OnSessionStateChanged(null,null); //Call the Facebook Log In Button's event here.
}
I hope this somewhat solves your problem.