In storybook MDX file, how to I enter literal markup - storybook

I created a story using MDX. I want to demonstrate my inhouse-styles for buttons.
The story contains the following:
<a class="btn btn-primary">
Primary Button
</a>
When rendered, story book shows
<a class="sbdocs sbdocs-a btn btn-primary css-19nbuh3" target="_top">
Primary Button
<a>
As a result, my button does not display with the correct css.
How do I prevent storybook MDX from changing markup?

Put your markup inside of <Preview> tags:
<Preview>
<a class="btn btn-primary">
Primary Button
</a>
</Preview>

Related

Placing Link Text Within a Button in Angular App

I have an href link that triggers a download located within a button in my Angular component HTML. I can see both the button and the highlighted text link in my browser. However, when I click the link, nothing happens - in terms of triggering the download. This is what I have:
<button class="email-prompt-button" md-button>
<a [href]="fileUrl" download="file.txt" class="btn-link">Download File</a>
</button>
Now, if I remove the button, and just have the a tag, it works:
<a [href]="fileUrl" download="file.txt" class="btn-link">Download File</a>
How can I get this to works as link text within a button?
Why don't you shape your anchor tag shapes to look like a button by applying custom css
or
If you're using Bootstrap you can apply below classes:
btn btn-primary
Just like
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<a [href]="fileUrl" download="file.txt" class="btn btn-primary btn-link">Download File</a>

Icons (fontawesome, material icons) with blinking !/? issue

I never had this kind of problem - and I don't know why..
some icons are missing and appearing blinking with "?/!"
what is happening?
Its a submit button. I have the same icon in another button - and it's ok there.
<button type="submit" id="submit"
class="btn btn-inv btn-lg" style="--h: #822584"
onclick="javascript:document.getElementById('classid').value='WAI-04'">
<i class="fa fa-thumbs-o-up"></i> SIGN!
</button>
any idea?
tks!!
If you are using the newest version of Font-Awesome, fa is no longer a valid class. It has been replaced with fas (solid), and fab (brands). For a thumbs up, you would use:
<i class="fas fa-thumbs-up"></i>
Here is the documentation if you want to learn more.

"Guillemet" arrows do not generate for buttons in Rails link_to helper

When I am putting a page together with Bootstrap, I have a primary button that looks ok with the "guillemet" arrows added to it, like so (denoted by &raquo):
<a class="btn btn-primary btn-md" href="#" role="button">Play Game 2 »</a>
I am trying to make a similar button in a Rails project when I generate a button using the link_to helper:
<a class="btn btn-primary btn-md" <%= link_to "Play Game 1 &raquo", trivia_path %> </a>
When inserting the guillemet into the "Play Game 1" text, it delivers it as text and fails to generate an arrow. After experimenting with putting it in single quotes and moving it outside of the <%>, the page still renders it as text.
How do you generate styling like that within a link_to helper?
This should work (no need to surround in the <a> tags as the link to helper will do that for you):
<%= link_to "Play Game 1 »".html_safe, trivia_path, class: "btn btn-primary btn-md" %>
Sorry, I misunderstood your original issue, but the edited code above should work - I tested it in a rails app and it looked fine.

Showing a loading bar inside a button when it's clicked

I have this simple thing to do in angularjs that require a bit of dom manipulation, and i think it suppose to be a directive of some kind but i have no idea how to approach it.
I have this simple button: (html)
<button class="btn btn-success" style='margin-bottom:17px' style='margin-right:5px;' ng-show='pageToShow < pages.length-1' ng-click='changePage("next")'>
<span class="glyphicon glyphicon-arrow-right" style='margin-right:5px' aria-hidden="true"></span>Next
</button>
When i click it, i want inside of it, instead! of the glyphicon, a moving gif, like this:
1) How to remove the already existing img inside of the button and replace it?
2) I want to have other types of spinners, not the rounded one, how can i change the default spinner?
How can i do so?
Check out this directive, it does exactly what you want:
(offine)
And a demo:
(offline)
You can change the classes of the button-prepend="" and spinner-icon="" to a css-class that defines your own spinners/gifs.
You can create your own loading gif with http://www.ajaxload.info. Then, use ng-show to determine if the gif or icon should be visible.
<button ng-click="loading = !loading;" class="btn btn-success">
<img ng-show="loading" src='http://i.imgur.com/1HDbs9b.gif' />
<span ng-show="!loading" class="glyphicon glyphicon-arrow-right"></span>
Next
</button>
http://plnkr.co/edit/6N4x5bZyiilV2GMqCP48?p=preview

Preventing postback of bootstrap dropdown

I'm using the bootstrap dropdown component, which for me currently looks like this:
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" id="btnSaukList" data-toggle="dropdown" runat="server" style="width: 100%">
Select a Saukville contact
<span class="caret"></span>
</button>
<ul id="ulSaukContact" class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1" runat="server" style="width: 100%">
<!--NOTE: Intentionally left blank; li's are generated by code behind to populate users from Sharepoint.-->
</ul>
<input id="inpSaukValue" type="hidden" />
</div>
(default code sample here - as you can see, mine isn't that different structurally)
My problem is that every time I click a dropdown item, a postback is fired (browser jumps to the top of the page). I'm pretty sure this is because the default code Bootstrap uses is <button> which always includes a postback.
According to other SO articles regarding this issue, it's recommended to use an <input> or <asp:Button> instead. Well I can't do either...
<asp:Button> does not support text between the opening and closing tags.
<input> does not support the data-toggle attribute, which it seems the dropdown needs.
I've also tried adding onclick="return false;" to my <button> to no avail.
I'm new to bootstrap and to an extent, ASP.net.
UPDATE:
It wasn't a postback, it was a link to "#", I was confused, sorry!
I think I was confused about this one, and labelled the problem as a postback - it wasn't. In Bootstrap's default code snippet, every dropdown item includes a link to "#". Clicking a link to that(<a href="#">) will send the browser to the top of the page. I thought this was a page refresh but it wasn't actually refreshed.
A quick fix is to replace href="#" with href="Javascript:;". If anyone has a better solution, do share...

Resources