Last active
June 27, 2022 19:21
-
-
Save jwx/d76c127dffe657913c2982daa0e0b608 to your computer and use it in GitHub Desktop.
peasy-ui-grid-menu
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Dumber Gist</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> | |
</head> | |
<!-- | |
Dumber Gist uses dumber bundler, the default bundle file | |
is /dist/entry-bundle.js. | |
The starting module is pointed to "main" (data-main attribute on script) | |
which is your src/main.ts. | |
--> | |
<body> | |
<script src="/dist/entry-bundle.js" data-main="main"></script> | |
</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
{ | |
"dependencies": { | |
"peasy-ui": "latest" | |
} | |
} |
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
import { UI, UIView } from 'peasy-ui'; | |
import { Menu } from './menu'; | |
import 'styles.css'; | |
window.addEventListener('DOMContentLoaded', (event) => { | |
main(); | |
}); | |
let menu = null; | |
function main() { | |
const model = { | |
menu: null, | |
get showButton() { return menu == null }, | |
clicked: () => showMenu(), | |
} | |
UI.create(document.body, '<div><button ${ === showButton} ${click @=> clicked}>Show menu</button></div>', model); | |
setInterval(() => UI.update(), 1000 / 60); | |
} | |
function showMenu() { | |
menu = new Menu( | |
['one', 'two', 'three', 'four', 'five', 'six'], | |
(selected) => { | |
alert('Selected menu option: ' + selected); | |
menu = null; | |
}); | |
} |
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
.options { | |
border: 1px solid black; | |
display: flex; | |
flex-wrap: wrap; | |
padding: 5px; | |
width: 50%; | |
} | |
.option { | |
width: 50px; | |
padding: 5px; | |
margin: 5px; | |
background-color: lightblue; | |
} | |
.option.active { | |
background-color: skyblue; | |
color: red; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment