-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* broke out authenticated and non-authenticated layouts * added some tailwind stimulus components * wrote a simple stimulus component to drive the mobile nav UI * added a basic tailwind-based layout * some model tweaks
- Loading branch information
Showing
13 changed files
with
257 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
module ApplicationHelper | ||
def header_link_to(text, path) | ||
css_classes = if current_page?(path) | ||
"bg-gray-900 text-white rounded-md px-3 py-2 text-sm font-medium" | ||
else | ||
"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium" | ||
end | ||
|
||
link_to text, path, class: css_classes | ||
end | ||
|
||
def mobile_header_link_to(text, path) | ||
css_classes = if current_page?(path) | ||
"bg-gray-900 text-white block px-3 py-2 rounded-md text-base font-medium" | ||
else | ||
"text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium" | ||
end | ||
|
||
link_to text, path, class: css_classes | ||
end | ||
def user_gravatar(user:, css_classes: "h-8 w-8 rounded-full") | ||
gravatar_id = Digest::MD5::hexdigest(user.email.downcase) | ||
gravatar_url = "http://secure.gravatar.com/avatar/#{gravatar_id}" | ||
image_tag(gravatar_url, alt: user.name, class: css_classes) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// Import and register all your controllers from the importmap under controllers/* | ||
// This file is auto-generated by ./bin/rails stimulus:manifest:update | ||
// Run that command whenever you add a new controller or create them with | ||
// ./bin/rails generate stimulus controllerName | ||
|
||
import { application } from "controllers/application" | ||
import { application } from "./application" | ||
|
||
// Eager load all controllers defined in the import map under controllers/**/*_controller | ||
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" | ||
eagerLoadControllersFrom("controllers", application) | ||
import MobileNavController from "./mobile_nav_controller" | ||
application.register("mobile-nav", MobileNavController) | ||
|
||
// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!) | ||
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading" | ||
// lazyLoadControllersFrom("controllers", application) | ||
import WorkWeekController from "./work_week_controller" | ||
application.register("work-week", WorkWeekController) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
// Connects to data-controller="mobile-nav" | ||
export default class extends Controller { | ||
static targets = ['open', 'close'] | ||
static values = { open: Boolean, default: false } | ||
|
||
openValueChanged() { | ||
if (this.openValue === true) { | ||
this.show() | ||
} else { | ||
this.hide() | ||
} | ||
} | ||
|
||
show() { | ||
this.closeTarget.classList.replace('hidden', 'block') | ||
this.openTarget.classList.replace('block', 'hidden') | ||
document.getElementById('mobile-menu').classList.replace('hidden', 'block') | ||
this.openValue = true; | ||
} | ||
|
||
hide() { | ||
this.closeTarget.classList.replace('block', 'hidden') | ||
this.openTarget.classList.replace('hidden', 'block') | ||
document.getElementById('mobile-menu').classList.replace('block', 'hidden') | ||
this.openValue = false | ||
} | ||
|
||
toggle() { | ||
this.openValue = !this.openValue | ||
} | ||
} | ||
|
2 changes: 1 addition & 1 deletion
2
...avascript/controllers/hello_controller.js → ...cript/controllers/work_week_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
// Connects to data-controller="work-week" | ||
export default class extends Controller { | ||
connect() { | ||
this.element.textContent = "Hello World!" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>StaffplanRedux</title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<%= csrf_meta_tags %> | ||
<%= csp_meta_tag %> | ||
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> | ||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> | ||
<%= javascript_importmap_tags %> | ||
</head> | ||
|
||
<body> | ||
<main class="container mx-auto mt-28 px-5 flex"> | ||
<%= yield %> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<% content_for(:header) do %> | ||
<%= current_user == @viewing_user ? "My StaffPlan" : "#{@viewing_user.name}'s StaffPlan" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters