Skip to content

Commit 21d02f9

Browse files
authored
Merge pull request #12 from SnippetSafe/styling-responsive-modals
Styling responsive modals
2 parents 920935d + 8510329 commit 21d02f9

File tree

7 files changed

+47
-71
lines changed

7 files changed

+47
-71
lines changed

app/assets/stylesheets/helpers.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626

2727
// DISPLAY
2828

29-
.block { display: block; }
30-
.inline-block { display: inline-block; }
31-
.hidden { display: none !important; }
3229
.selected {
3330
background-color: $color-light;
3431

app/views/layouts/application.html.erb

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -33,60 +33,16 @@
3333
<%= render partial: 'shared/toast' %>
3434
<%= render partial: 'shared/topbar' %>
3535

36-
<!--
37-
This example requires Tailwind CSS v2.0+
38-
39-
This example requires some changes to your config:
40-
41-
```
42-
// tailwind.config.js
43-
module.exports = {
44-
// ...
45-
plugins: [
46-
// ...
47-
require('@tailwindcss/forms'),
48-
]
49-
}
50-
```
51-
-->
52-
<div class="max-w-6xl mx-auto py-4 sm:px-6 lg:px-8">
36+
<div class="max-w-6xl mx-auto py-4 md:px-4 lg:px-8">
5337
<div class="min-h-screen bg-gray-100">
5438
<!-- When the mobile menu is open, add `overflow-hidden` to the `body` element to prevent double scrollbars -->
5539
<!-- On: "fixed inset-0 z-40 overflow-y-auto", Off: "undefined" -->
5640

57-
<div class="max-w-3xl mx-auto lg:max-w-7xl lg:grid lg:grid-cols-12 lg:gap-8">
41+
<div class="mx-auto lg:max-w-7xl lg:grid lg:grid-cols-12 lg:gap-8">
5842
<main class="lg:col-span-9 xl:col-span-9">
5943
<%= yield %>
6044
</main>
61-
<aside class="xl:block xl:col-span-3">
62-
<div class="sticky position-sticky--topbar space-y-4">
63-
<% if user_signed_in? %>
64-
<%=
65-
button_tag(
66-
'NEW SNIPPET',
67-
class: 'w-full button--cta-primary flex justify-center',
68-
data: {
69-
controller: 'modal',
70-
action: 'modal#present',
71-
modal_url_value: new_modals_snippet_path(folder_id: new_snippet_folder_id)
72-
}
73-
)
74-
%>
75-
<% else %>
76-
<div class="flex justify-center">
77-
<%= button_tag('LOG IN', type: :button, class: "flex-1 flex justify-center button--cta-tertiary", data: { controller: "modal", modal_url_value: sign_in_modals_users_path, action: "click->modal#present" }) %>
78-
<%= button_tag('SIGN UP', type: :button, class: "flex-1 flex justify-center button--cta-primary ml-2", data: { controller: "modal", modal_url_value: sign_up_modals_users_path, action: "click->modal#present" }) %>
79-
</div>
80-
<% end %>
81-
82-
<%= render partial: 'shared/connect' %>
83-
84-
<%# <%= render 'shared/cards/card' do %>
85-
<%# <h4 class="text-center">Popular</h4> %>
86-
<%# <% end %>
87-
88-
</div>
89-
</aside>
45+
<%= render partial: 'shared/sidebar' %>
9046
</div>
9147
</div>
9248
</div>

app/views/layouts/modal.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
From: "opacity-100 translate-y-0 sm:scale-100"
3434
To: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
3535
-->
36-
<div class="z-10 relative mt-2 inline-block align-bottom bg-white rounded-sm px-4 pt-5 pb-4 text-left shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-2xl sm:w-full sm:p-6" role="dialog" aria-modal="true" aria-labelledby="modal-headline" data-modal-target="body">
36+
<div class="z-10 relative mt-2 inline-block align-bottom bg-white rounded-sm px-4 pt-5 pb-4 text-left shadow-xl transform transition-all sm:my-8 sm:align-middle w-full sm:max-w-2xl sm:w-full sm:p-6" role="dialog" aria-modal="true" aria-labelledby="modal-headline" data-modal-target="body">
3737
<span data-action="click->modal#close" title="Close modal" class="hover:bg-cyan-hover transition cursor-pointer absolute z-12 -top-4 -right-5 inline-flex items-center p-1 border border-transparent rounded-full shadow-sm text-white bg-cyan mr-2">
3838
<%= render partial: 'shared/icons/close', locals: { height: 7, width: 7, color: 'text-white' } %>
3939
</span>

app/views/modals/snippets/edit.html.erb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,25 @@
1212
class="mt-4"
1313
>
1414
<%= form_for @snippet, remote: true, html: { data: { type: "html", action: "ajax:success->snippets#onUpdateSuccess ajax:error->snippets#onUpdateError" } } do |f| %>
15+
1516
<div>
16-
<%= f.text_field :description, { class: "new-snippet--description", placeholder: "Snippet title...", class: "block w-full mb-4 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-sm" } %>
17-
<%= f.text_area :body, { data: { codemirror_target: 'mirror' }, class: "font-mono h-80 block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-sm" } %>
17+
<%= f.text_field :description, { class: "new-snippet--description", placeholder: "Snippet title...", class: "block sm:w-full mb-4 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-sm" } %>
18+
<%= f.text_area :body, { data: { codemirror_target: 'mirror' }, class: "font-mono h-80 block sm:w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block sm:text-sm border-gray-300 rounded-sm" } %>
1819
</div>
1920

20-
<div class="flex mt-4">
21+
<div class="flex mt-4 flex-wrap">
2122
<div class="flex flex-1 items-center">
2223
<%= render partial: 'shared/form/toggle', locals: { form: f, field: :public, enabled_text: 'Private', disabled_text: 'Public', enabled: !@snippet.public, flip: true } %>
2324
</div>
2425

25-
<div class="flex flex-auto justify-end">
26-
<%= f.select :language_id, options_from_collection_for_select(@languages, :id, :name, @snippet.language_id), { prompt: 'Select language...' }, class: "block w-40 pl-3 pr-10 py-1 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-sm", data: { action: 'change->codemirror#updateMode' } %>
27-
<%= f.select :folder_id, options_from_collection_for_select(@folders, :id, :name, @folder.id), { prompt: 'Select folder...' }, { class: "ml-1 block w-40 pl-3 pr-10 py-1 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-sm" } %>
28-
<%= f.submit 'Update', class: "button--cta-primary ml-4" %>
26+
<div class="flex flex-auto justify-end mt-2 sm:mt-0">
27+
<div class="flex flex-wrap">
28+
<%= f.select :language_id, options_from_collection_for_select(@languages, :id, :name, @snippet.language_id), { prompt: 'Select language...' }, class: "mr-1 block w-40 pl-3 pr-10 py-1 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-sm", data: { action: 'change->codemirror#updateMode' } %>
29+
<%= f.select :folder_id, options_from_collection_for_select(@folders, :id, :name, @folder.id), { prompt: 'Select folder...' }, { class: "mt-1 sm:mt-0 block w-40 pl-3 pr-10 py-1 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-sm" } %>
30+
</div>
31+
<div class="flex items-end">
32+
<%= f.submit 'Update', class: "button--cta-primary ml-4" %>
33+
</div>
2934
</div>
3035
</div>
3136
<% end %>

app/views/shared/_sidebar.html.erb

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
<div class="sidebar--wrapper">
2-
<div class="card--container card--container-padding text-center margin-bottom">
3-
<span class="bold"><%= @page_title.upcase %></span>
4-
</div>
5-
6-
<div class="flex justify-center">
7-
<%= link_to('NEW SNIPPET', @modal_url, data: { controller: 'modal', action: 'modal#present', modal_url_value: @modal_url }, class: 'button--sidebar') %>
8-
</div>
1+
<aside class="hidden lg:block xl:col-span-3 md:col-span-3">
2+
<div class="sticky position-sticky--topbar space-y-4">
3+
<% if user_signed_in? %>
4+
<%=
5+
button_tag(
6+
'NEW SNIPPET',
7+
class: 'w-full button--cta-primary flex justify-center',
8+
data: {
9+
controller: 'modal',
10+
action: 'modal#present',
11+
modal_url_value: new_modals_snippet_path(folder_id: new_snippet_folder_id)
12+
}
13+
)
14+
%>
15+
<% end %>
16+
17+
<%= render partial: 'shared/connect' %>
918

10-
<%= render partial: 'shared/connect', locals: { users_for_connect: @users_for_connect }%>
11-
</div>
19+
<div>
20+
<p class="text-center text-xs text-gray-500">by <%= link_to '@lewisyoul', 'https://twitter.com/lewisyoul', target: '_blank', class: 'hover:underline' %></p>
21+
</div>
22+
23+
</div>
24+
</aside>

app/views/shared/_topbar.html.erb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div id="header">
22
<div id="header-nav-wrapper">
33
<div id="header-nav" class="position-relative">
4-
<div class="flex items-center flex-1">
4+
<div class="flex items-center flex-1 ml-4 md:ml-4 lg:ml-0">
55
<%= link_to root_path, class: 'flex-1' do %>
6-
<%= render partial: 'shared/icons/logo_full', locals: { height: 12 } %>
6+
<%= render partial: 'shared/icons/logo_full', locals: { height: 12, width: 28 } %>
77
<% end %>
88
</div>
99

@@ -27,6 +27,11 @@
2727
<div class="flex items-center flex-1 justify-end">
2828
<%= render partial: 'shared/profile_nav_item.html.erb' %>
2929
</div>
30+
<% else %>
31+
<div class="flex flex-1 justify-end items-center">
32+
<%= button_tag('LOG IN', type: :button, class: "flex justify-center button--cta-tertiary", data: { controller: "modal", modal_url_value: sign_in_modals_users_path, action: "click->modal#present" }) %>
33+
<%= button_tag('SIGN UP', type: :button, class: "flex justify-center button--cta-primary ml-2", data: { controller: "modal", modal_url_value: sign_up_modals_users_path, action: "click->modal#present" }) %>
34+
</div>
3035
<% end %>
3136
</div>
3237
</div>

app/views/shared/icons/_logo_full.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<svg class="h-<%= height %>" preserveAspectRatio="xMinYMid meet" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" viewBox="159 55.04887585532748 325.9100841661414 153.06110424947616" width="321.91" height="149.06"><defs><path d="M160 56.05L480 56.05L480 204.35L160 204.35L160 56.05Z" id="a1k2GLJvtu"></path><path d="M160 80L220 80L220 100L160 100L160 80Z" id="a4IJ9oIgYj"></path><path d="M181.08 120L240 120L240 140L181.08 140L181.08 120Z" id="bQGaJr4c2"></path><path d="M160 160L220 160L220 180L160 180L160 160Z" id="aPdPIrvc3"></path><text id="a4z2VN0QlB" x="267.25" y="102.28" font-size="57" font-family="Scope One" font-weight="700" font-style="normal" letter-spacing="0" alignment-baseline="before-edge" transform="matrix(1 0 0 1 -7.25475491920772 -37.89210842727208)" style="line-height:100%" xml:space="preserve" dominant-baseline="text-before-edge"><tspan x="267.25" dy="0em" alignment-baseline="before-edge" dominant-baseline="text-before-edge" text-anchor="start">SNIPPET</tspan></text><style id="scopeone700normal">
1+
<svg class="h-<%= height %> w-<%= width %>" preserveAspectRatio="xMinYMid meet" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" viewBox="159 55.04887585532748 325.9100841661414 153.06110424947616" width="321.91" height="149.06"><defs><path d="M160 56.05L480 56.05L480 204.35L160 204.35L160 56.05Z" id="a1k2GLJvtu"></path><path d="M160 80L220 80L220 100L160 100L160 80Z" id="a4IJ9oIgYj"></path><path d="M181.08 120L240 120L240 140L181.08 140L181.08 120Z" id="bQGaJr4c2"></path><path d="M160 160L220 160L220 180L160 180L160 160Z" id="aPdPIrvc3"></path><text id="a4z2VN0QlB" x="267.25" y="102.28" font-size="57" font-family="Scope One" font-weight="700" font-style="normal" letter-spacing="0" alignment-baseline="before-edge" transform="matrix(1 0 0 1 -7.25475491920772 -37.89210842727208)" style="line-height:100%" xml:space="preserve" dominant-baseline="text-before-edge"><tspan x="267.25" dy="0em" alignment-baseline="before-edge" dominant-baseline="text-before-edge" text-anchor="start">SNIPPET</tspan></text><style id="scopeone700normal">
22
@font-face {
33
font-family: "Scope One";
44
font-weight: 700;

0 commit comments

Comments
 (0)