Skip to content

Commit 53a94c2

Browse files
author
Bruno P. Kinoshita
committed
Initial commit
0 parents  commit 53a94c2

File tree

6 files changed

+201
-0
lines changed

6 files changed

+201
-0
lines changed

Diff for: .gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# History files
2+
.Rhistory
3+
.Rapp.history
4+
5+
# Session Data files
6+
.RData
7+
8+
# Example code in package build process
9+
*-Ex.R
10+
11+
# Output files from R CMD build
12+
/*.tar.gz
13+
14+
# Output files from R CMD check
15+
/*.Rcheck/
16+
17+
# RStudio files
18+
.Rproj.user/
19+
20+
# produced vignettes
21+
vignettes/*.html
22+
vignettes/*.pdf
23+
24+
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
25+
.httr-oauth
26+
27+
# knitr and R markdown default cache directories
28+
/*_cache/
29+
/cache/
30+
31+
# Temporary files created by R markdown
32+
*.utf8.md
33+
*.knit.md

Diff for: README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# NIWA Style guide for R Shiny Applications
2+
3+
NIWA has a default style guide, created in conjunction with communications team and IT systems development.
4+
5+
This style guide is applied to most systems within NIWA, giving a consistent image for NIWA systems.
6+
7+
The file `niwastyleguide.R` contains the functions used to create the top header, the menu bar, and the footer.
8+
You can modify the links of your application by editing this file.
9+
10+
Here's a screen shot of the default R Shiny app with the NIWA Style Guide.
11+
12+
![Screen shot of the default R Shiny app with the NIWA Style Guide](screenshot.png)
13+
14+
For more information, visit the [NIWA Style Guide home page](https://styles.niwa.co.nz/).

Diff for: niwastyleguide.R

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# This file contains custom functions for NIWA Style guide. You are free to edit the links, and menu items.
2+
# Colours, and position of certain elements will be automatically determined for your application.
3+
# Search for TODO to locate where to change links.
4+
5+
#' Add the application menu from NIWA.
6+
#'
7+
#' You can customize the menu links in this function.
8+
niwaMenu <- function() {
9+
tags$div(
10+
class = "navbar navbar-default",
11+
role = "navigation",
12+
tags$div(
13+
class = "container-fluid",
14+
tags$div(
15+
class = "navbar-header",
16+
tags$button(
17+
type = "button",
18+
class = "navbar-toggle",
19+
`data-toggle` = "collapse",
20+
`data-target` = ".navbar-collapse",
21+
tags$span(class = "sr-only", "Toggle navigation"),
22+
tags$span(class = "icon-bar"),
23+
tags$span(class = "icon-bar"),
24+
tags$span(class = "icon-bar")
25+
)
26+
),
27+
tags$div(
28+
class = "collapse navbar-collapse",
29+
tags$ul(
30+
class = "nav navbar-nav",
31+
# TODO: You can customize the menu links here
32+
tags$li(class = "active", tags$a(href = "/", "Home")),
33+
tags$li(tags$a(href = "https://www.niwa.co.nz", "NIWA Web site")),
34+
tags$li(
35+
tags$a(href = "https://en.wikipedia.org/wiki/National_Institute_of_Water_and_Atmospheric_Research", "NIWA Wikipedia page")
36+
)
37+
)
38+
)
39+
)
40+
)
41+
}
42+
43+
#' Add the NIWA banner, normally at the top.
44+
#'
45+
#' @param title The application title. Defaults to 'NIWA R Shiny Application'
46+
#' @param link The application link. Defaults to 'https://www.niwa.co.nz/'
47+
niwaBanner <- function(title = "NIWA R Shiny Application", link = "https://www.niwa.co.nz/") {
48+
tags$div(class = "banner",
49+
role = "banner",
50+
tags$div(class = "container-fluid",
51+
tags$div(
52+
class = "row",
53+
# Set the title of your application here
54+
tags$a(title,
55+
class = "logo",
56+
href = link)
57+
)))
58+
}
59+
60+
#' Add the applicatoin footer from NIWA.
61+
#'
62+
#' You can customize the footer links in this function.
63+
niwaFooter <- function() {
64+
tags$footer(role = "contentinfo",
65+
tags$div(class = "container",
66+
tags$div(
67+
class = "row",
68+
tags$a(href = "/", class = "logo"),
69+
tags$ul(
70+
# TODO: You can customize the header links here
71+
tags$li(
72+
tags$a(href = "https://www.niwa.co.nz/privacy-policy", "NIWA Privacy Policy")
73+
),
74+
tags$li(id = "copyrightNiwa", class = "pull-right", "Copyright 2017 NIWA")
75+
)
76+
)))
77+
}

Diff for: screenshot.png

46.6 KB
Loading

Diff for: server.R

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# This is the server logic of a Shiny web application. You can run the
3+
# application by clicking 'Run App' above.
4+
#
5+
# Find out more about building applications with Shiny here:
6+
#
7+
# http://shiny.rstudio.com/
8+
#
9+
10+
library(shiny)
11+
12+
# Define server logic required to draw a histogram
13+
shinyServer(function(input, output) {
14+
15+
output$distPlot <- renderPlot({
16+
17+
# generate bins based on input$bins from ui.R
18+
x <- faithful[, 2]
19+
bins <- seq(min(x), max(x), length.out = input$bins + 1)
20+
21+
# draw the histogram with the specified number of bins
22+
hist(x, breaks = bins, col = 'darkgray', border = 'white')
23+
24+
})
25+
26+
})

Diff for: ui.R

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Application: R Shiny example with NIWA Style guide (https://styles.niwa.co.nz).
2+
# Author: NIWA/ITSD
3+
# Source: https://git.niwa.local/ITSD/shiny-styleguide
4+
# Issues: https://git.niwa.local/ITSD/shiny-styleguide/issues
5+
# For more information: https://styles.niwa.co.nz
6+
7+
library(shiny)
8+
9+
# Load UI customization functions
10+
source('./niwastyleguide.R')
11+
12+
# Define UI for application that draws a histogram
13+
shinyUI(
14+
fluidPage(
15+
theme = "https://styles.niwa.co.nz/dist/css/bootstrap.min.css",
16+
style = "margin: 0px !important; border: 0px !important; padding: 0px !important;",
17+
# NIWA Style guide. See https://styles.niwa.co.nz for more.
18+
tags$head(
19+
tags$link(rel = "stylesheet", type = "text/css", href = "https://styles.niwa.co.nz/dist/css/bootstrap-theme.min.css")
20+
),
21+
22+
# NIWA Banner
23+
niwaBanner(title = 'NIWA R Shiny App', link = 'https://github.com/niwa/'),
24+
25+
niwaMenu(),
26+
tags$br(class = "clearfix;"),
27+
28+
# two columns layout
29+
tags$div(class = "row-fluid",
30+
sidebarPanel(
31+
# TODO: your sidebar content goes here
32+
sliderInput(
33+
"bins",
34+
"Number of bins:",
35+
min = 1,
36+
max = 50,
37+
value = 30
38+
)
39+
),
40+
mainPanel(# TODO: your main content goes here
41+
plotOutput("distPlot"))),
42+
43+
niwaFooter(),
44+
45+
# Placed at the end of the document so the pages load faster
46+
tags$head(
47+
tags$script(src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"),
48+
tags$script(src = "https://styles.niwa.co.nz/dist/js/bootstrap.min.js")
49+
)
50+
)
51+
) # end

0 commit comments

Comments
 (0)