Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap Alerts (cloned) in Tachyons #8

Open
nelsonic opened this issue Apr 12, 2017 · 1 comment
Open

Bootstrap Alerts (cloned) in Tachyons #8

nelsonic opened this issue Apr 12, 2017 · 1 comment

Comments

@nelsonic
Copy link
Member

nelsonic commented Apr 12, 2017

The default UI Theme/Framework in Phoenix (Web Framework) is Twitter Bootstrap.

There is a reason for using Bootstrap: (most) "developers" are (way) too lazy to learn CSS
so giving them a "style guide" they can copy-paste from means they can make their apps look nice with minimal effort. So, we @dwyl need to help make it easy for "busy" people to use Tachyons by copy-pasting. For example: ...

In Phoenix the get_flash view helper is used to display an :info or :error messages using Bootstrap's alert UI:

bootstrap alerts

Notice the "Copy" button right there next to the code example? #CopyPasteDrivenDevelopment

Implementing Alerts in Tachyons

Unpack the CSS in Bootstrap to Understand it

Inspect the element to see how it's constructed:
image

Read the CSS on the Bootstrap Component Guide so that it can be replicated in Tachyons. 🔍

Tachyons + HTML Code:

<p class="w-90 ba br2 pa3 ma2 green bg-washed-green" role="alert">
  <strong>Well done!</strong> You successfully read this important alert message.
</p>
<p class="w-90 ba br2 pa3 ma2 blue bg-washed-blue" role="alert">
  <strong>Heads up!</strong> This alert needs your attention, but it's not super important.
</p>
<p class="w-90 ba br2 pa3 ma2 gold bg-washed-yellow" role="alert">
  <strong>Warning!</strong> Better check yourself, you're not looking too good.
</p>
<p class="w-90 ba br2 pa3 ma2 red bg-washed-red" role="alert">
  <strong>Oh snap!</strong> Change a few things up and try submitting again.
</p>

Result:

alerts in tachyons

Note: I am deliberately limiting myself to using only the default Colors for Text, Border and Background to keep it simple because if we keep the Colors consistent all other components will match. We will be building a way of doing "Dynamic Components with Tachyons" soon, but for now we just want to get our "cloned" components as close as possible. Also, I prefer the colors that @mrmrs has chosen as they are brighter and thus more legible and friendly! 😉

Explanation of Tachyons Styles/Code

Usage in Context of a Phoenix Project

<% # Alerts for Info/Errors using Tachyons see: https://git.io/vSMY7
  info = get_flash(@conn, :info)
  error = get_flash(@conn, :error)
%>
<%= if info do %>
  <p class="w-90 ba br2 pa3 ma2 green bg-washed-green" role="alert">
    <%= info %>
  </p>
<% end %>
<%= if error do %>
<p class="w-90 ba br2 pa3 ma2 red bg-washed-red" role="alert">
  <%= error %>
</p>
<% end %>

Practical Example in a @dwyl Client Project?

Where is this used? see: https://github.com/healthlocker/healthlocker/search?utf8=%E2%9C%93&q=b--hl-yellow where a custom border color is used for the alert.

Can We Divide and Conquer This...?

Can we build a Complete Component Guide for @dwyl's Projects? see: #9 🌈

@nogainbar
Copy link
Member

Interesting! I know its down to a matter of taste and 'spirit of times' but I cannot help but say that even by just translating the Bootstrap elements to Tachyon's world, is making those immediately look better ;-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants