User:Lucas Werkmeister (WMDE)/Working on OOUI
This page is currently a draft.
|
When you want to work on the OOUI code itself, e.âŻg. to fix a bug, you typically donât want to do this from inside MediaWiki: MediaWikiâs source code repository only syncs up with OOUI on each OOUI release, without reflecting the details of the work between releases, and it also merges multiple source code files together, making them harder to navigate.
Instead, youâll want to set up a simple standalone web page using OOUI.
First, in a new directory run npm install oojs-ui
to install its dependencies
(though we wonât load OOUI itself from there);
then, create an index.html
file like the following
(based on the OOUI ToDo App Tutorial:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>OOUI test</title>
<!-- jQuery -->
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<!-- OOjs -->
<script src="node_modules/oojs/dist/oojs.jquery.min.js"></script>
<!-- OOUI -->
<script src="oojs-ui/dist/oojs-ui.js"></script>
<!-- OOUI theme -->
<script src="oojs-ui/dist/oojs-ui-wikimediaui.js"></script>
<link rel="stylesheet" href="oojs-ui/dist/oojs-ui-wikimediaui.css">
<!-- custom -->
<link rel="stylesheet" href="test.css">
<script src="test.js"></script>
</head>
<body>
<div class="wrapper">
<h1>OOUI test page</h1>
</div>
</body>
</html>
Youâll place your own code in test.js
and/or test.css
, for example:
$( function () {
var widget = new OO.ui.LabelWidget( { label: 'a label' } );
$( '.wrapper' ).append( widget.$element );
} );
The HTML file expects to load OOUI from an oojs-ui/
directory,
so you first need to clone it and set it up:
git clone ssh://<username>@gerrit.wikimedia.org:29418/oojs/ui.git oojs-ui
cd oojs-ui
npm install
grunt build
Then, whenever youâve made a change to the OOUI source code,
run grunt build
again to rebuild the files in dist/
that the HTML file loads.
(Unfortunately, this takes about 1½ minutes on my system,
and includes re-rasterizing all the SVG images to PNG files.
This is the part that Iâm sure can be improved.)