Skip to content

Commit

Permalink
mcplant experience
Browse files Browse the repository at this point in the history
  • Loading branch information
TodePond committed Jan 8, 2025
1 parent a60f47f commit f92d8b5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
17 changes: 15 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
</select>
<button id="export-button">⇓ Export</button>
<div class="mcplant">
<button>🌱 McPlant</button>
<span class="tooltip">Vegetarianism propaganda in my burger menu?!</span>
<button id="mcplant-button">🌱 McPlant</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -132,6 +131,20 @@ <h1>Are you sure?</h1>
</dialog>
</div>

<div class="dialog-container">
<dialog id="alert-dialog">
<!-- <h1>Alert</h1> -->
<form method="dialog">
<p>
<span id="alert-message">alert</span>
</p>
<p>
<button id="alert-ok-button">OK</button>
</p>
</form>
</dialog>
</div>

<div class="dialog-container">
<dialog id="about-dialog">
<form method="dialog">
Expand Down
7 changes: 7 additions & 0 deletions src/alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const alertDialog = document.querySelector('#alert-dialog');
const alertMessageSpan = document.querySelector('#alert-message');

export async function nudelAlert(alertMessage = 'alert!') {
alertMessageSpan.textContent = alertMessage;
alertDialog.showModal();
}
4 changes: 3 additions & 1 deletion src/confirm.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const youSureDialog = document.querySelector('#you-sure-dialog');
const yesButton = document.querySelector('#you-sure-yes-button');
const noButton = document.querySelector('#you-sure-no-button');
const actionDescriptionSpan = document.querySelector('#you-sure-action-description');

export async function nudelConfirm() {
export async function nudelConfirm(actionDescription = 'do that') {
actionDescriptionSpan.textContent = actionDescription;
youSureDialog.showModal();

return new Promise((resolve) => {
Expand Down
10 changes: 10 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { applySettingsToNudel, getSettings } from './settings.js';
import { vim } from '@replit/codemirror-vim';
import { Compartment } from '@codemirror/state';
import './style.css';
import { nudelConfirm } from './confirm.js';
import { nudelAlert } from './alert.js';

export const editorViews = new Map();

Expand Down Expand Up @@ -278,5 +280,13 @@ window.addEventListener('message', (event) => {
}
});

const mcPlantButton = document.querySelector('#mcplant-button');
mcPlantButton.addEventListener('click', async () => {
const result = await nudelConfirm('eat a mcplant');
if (result) {
nudelAlert('You eat the McPlant. It tastes just like a real burger.');
}
});

session.initialize();
applySettingsToNudel();
18 changes: 0 additions & 18 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -463,21 +463,3 @@ iframe#shader {
.dropdown:hover .dropdown-content {
display: flex;
}

.mcplant {
position: relative;
}

.tooltip {
display: none;
position: absolute;
right: 100%;
white-space: nowrap;
background: black;
color: white;
padding: 4px;
}

.mcplant:hover .tooltip {
display: block;
}

0 comments on commit f92d8b5

Please sign in to comment.