cjerzak commited on
Commit
7165748
·
verified ·
1 Parent(s): 7832369

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +100 -4
app.R CHANGED
@@ -70,14 +70,17 @@ plot_factor <- function(pi_star_list,
70
  y = "Probability"
71
  ) +
72
  # Apply Tufte's minimalistic theme
73
- theme_minimal(base_size = 16, base_line_size = 0) +
 
74
  theme(
75
  legend.position = "none",
76
  legend.title = element_blank(),
77
  panel.grid.major = element_blank(),
78
  panel.grid.minor = element_blank(),
79
- axis.line = element_line(color = "black", size = 0.3),
80
- axis.text.x = element_text(angle = 45, hjust = 1)
 
 
81
  ) +
82
  # Manual color scale for different strategies
83
  scale_color_manual(values = c("Democrat" = "#89cff0",
@@ -103,6 +106,99 @@ ui <- fluidPage(
103
  )
104
  ),
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  sidebarLayout(
107
  sidebarPanel(
108
  h4("Analysis Options"),
@@ -122,7 +218,7 @@ ui <- fluidPage(
122
  h4("Visualization"),
123
  selectInput("factor", "Select Factor to Display:",
124
  choices = NULL),
125
- hr(),
126
  selectInput("previousResults", "View Previous Results:",
127
  choices = NULL),
128
  hr(),
 
70
  y = "Probability"
71
  ) +
72
  # Apply Tufte's minimalistic theme
73
+ theme_minimal(base_size = 18,
74
+ base_line_size = 0) +
75
  theme(
76
  legend.position = "none",
77
  legend.title = element_blank(),
78
  panel.grid.major = element_blank(),
79
  panel.grid.minor = element_blank(),
80
+ axis.line = element_line(color = "black", size = 0.5),
81
+ axis.text.x = element_text(angle = 45,
82
+ hjust = 1,
83
+ margin = margin(r = 10)) # Add right margin
84
  ) +
85
  # Manual color scale for different strategies
86
  scale_color_manual(values = c("Democrat" = "#89cff0",
 
106
  )
107
  ),
108
 
109
+ # ---- Minimal "Share" button HTML + JS inlined ----
110
+ tags$div(
111
+ style = "text-align: left; margin: 0.5em 0 0.5em 0em;",
112
+ HTML('
113
+ <button id="share-button"
114
+ style="
115
+ display: inline-flex;
116
+ align-items: center;
117
+ justify-content: center;
118
+ gap: 8px;
119
+ padding: 5px 10px;
120
+ font-size: 16px;
121
+ font-weight: normal;
122
+ color: #000;
123
+ background-color: #fff;
124
+ border: 1px solid #ddd;
125
+ border-radius: 6px;
126
+ cursor: pointer;
127
+ box-shadow: 0 1.5px 0 #000;
128
+ ">
129
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
130
+ stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
131
+ <circle cx="18" cy="5" r="3"></circle>
132
+ <circle cx="6" cy="12" r="3"></circle>
133
+ <circle cx="18" cy="19" r="3"></circle>
134
+ <line x1="8.59" y1="13.51" x2="15.42" y2="17.49"></line>
135
+ <line x1="15.41" y1="6.51" x2="8.59" y2="10.49"></line>
136
+ </svg>
137
+ <strong>Share</strong>
138
+ </button>
139
+ '),
140
+ tags$script(
141
+ HTML("
142
+ (function() {
143
+ const shareBtn = document.getElementById('share-button');
144
+ // Reusable helper function to show a small “Copied!” message
145
+ function showCopyNotification() {
146
+ const notification = document.createElement('div');
147
+ notification.innerText = 'Copied to clipboard';
148
+ notification.style.position = 'fixed';
149
+ notification.style.bottom = '20px';
150
+ notification.style.right = '20px';
151
+ notification.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
152
+ notification.style.color = '#fff';
153
+ notification.style.padding = '8px 12px';
154
+ notification.style.borderRadius = '4px';
155
+ notification.style.zIndex = '9999';
156
+ document.body.appendChild(notification);
157
+ setTimeout(() => { notification.remove(); }, 2000);
158
+ }
159
+ shareBtn.addEventListener('click', function() {
160
+ const currentURL = window.location.href;
161
+ const pageTitle = document.title || 'Check this out!';
162
+ // If browser supports Web Share API
163
+ if (navigator.share) {
164
+ navigator.share({
165
+ title: pageTitle,
166
+ text: '',
167
+ url: currentURL
168
+ })
169
+ .catch((error) => {
170
+ console.log('Sharing failed', error);
171
+ });
172
+ } else {
173
+ // Fallback: Copy URL
174
+ if (navigator.clipboard && navigator.clipboard.writeText) {
175
+ navigator.clipboard.writeText(currentURL).then(() => {
176
+ showCopyNotification();
177
+ }, (err) => {
178
+ console.error('Could not copy text: ', err);
179
+ });
180
+ } else {
181
+ // Double fallback for older browsers
182
+ const textArea = document.createElement('textarea');
183
+ textArea.value = currentURL;
184
+ document.body.appendChild(textArea);
185
+ textArea.select();
186
+ try {
187
+ document.execCommand('copy');
188
+ showCopyNotification();
189
+ } catch (err) {
190
+ alert('Please copy this link:\\n' + currentURL);
191
+ }
192
+ document.body.removeChild(textArea);
193
+ }
194
+ }
195
+ });
196
+ })();
197
+ ")
198
+ )
199
+ ),
200
+ # ---- End: Minimal Share button snippet ----
201
+
202
  sidebarLayout(
203
  sidebarPanel(
204
  h4("Analysis Options"),
 
218
  h4("Visualization"),
219
  selectInput("factor", "Select Factor to Display:",
220
  choices = NULL),
221
+ br(),
222
  selectInput("previousResults", "View Previous Results:",
223
  choices = NULL),
224
  hr(),