This repository contains the styles and scripts for the DSM web development.
- Clone the repository
git clone git@github.com:ucsd-dsm/dsm-web-resources.git-
It is recommended to use VSCode as the IDE for development.
-
In VSCode, install the
Live Sass Compilerby Glenn Marks extension. There is another one by Ritwick Dey. Do not use that one. -
After installing the extension, go the extension settings
Go to Formats and click on
Edit in settings.json.Change the following configuration to the
settings.jsonfile. From:"liveSassCompile.settings.formats": [ { "format": "expanded", "extensionName": ".css", "savePath": null, "savePathReplacementPairs": null } ],
To:
"liveSassCompile.settings.formats": [ { "format": "expanded", "extensionName": ".css", "savePath": null, "savePathReplacementPairs": null }, { "format": "compressed", "extensionName": ".min.css", "savePath": null, "savePathReplacementPairs": { "scss": "css" } } ],
-
Click on
Watch Sassbutton on the bottom right corner of the window. -
Open a
.scssfile and start writing the styles. The.cssfile will be generated automatically.
-
There is no
tssupport for now. Just write the js code in thejsfolder. -
Install the
minifyextension by HookyQR.The settings are already configured in
.vscode/settings.jsonfile. You do not need to change anything.For the first time of each js file, you need to press
F1and typeMinify, then selectMinifyoption.Then you will see the minified version of the file in the same folder. Later on, the minified file will be generated automatically when you save the file.
-
There is a
playgroundfolder in the root directory. You can test the styles and scripts there. For example, there is atest_dsm_generic.htmlfile. You can test the styles and scripts there. -
To test the styles, you can use the
Live Serverby Ritwick Dey.Navigate to the
htmlfile and right-click on the file. SelectOpen with Live Server.This step is optional. You can open the
htmlfile in the browser as well, but live server has hot reload feature. It will reload the page automatically when you save the file. Otherwise, you have to refresh the page manually in the browser. -
Turn on Sass watch, Live Server, and have fun editing the styles and scripts.
-
The
mainbranch is for production. Use thedevbranch for development. -
This repository is public. Do not include any sensitive information in the files.
- To test the styles, include the
cssfile in thehtmlfile head section.Do not include the<link rel="stylesheet" href="../css/<FOLDER_NAME>/<FILE_NAME>.css">
scssfile in thehtmlfile. Thescssfile is for for your convenience to write the styles. Here you want to use the compiledcssfile.
- To test the scripts, include the
jsfile in thehtmlfile. Depending on the script, you can include the file in the head or body section.<script src="../js/<FOLDER_NAME>/<FILE_NAME>.js"></script>
-
For
cssandjs, we usejsdelivras the proxy CDN. You can use the following format.https://cdn.jsdelivr.net/gh/ucsd-dsm/dsm-web-resources@<BRANCH>/<PATH IN REPO>
For example, to include the
dsm-generic.cssfile in thehtmlfile, you can use the followinghttps://cdn.jsdelivr.net/gh/ucsd-dsm/dsm-web-resources@main/css/dsm_generic_styles/styles.min.css
Note: For production, use the minified version of the file,
min.cssforcssandmin.jsforjs. -
Reference the
css-
Use directly in the
htmlfile.<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/ucsd-dsm/dsm-web-resources@main/css/dsm_generic_styles/styles.min.css">
-
Use it on the top of your project styles. One can use the
@importrule to include the styles.@import url('https://cdn.jsdelivr.net/gh/ucsd-dsm/dsm-web-resources@main/css/dsm_generic_styles/styles.min.css'); /* Your styles */ h1 { color: red; }
The import rules are similar to scss import rules.
-
-
Reference the
js- Import the script to global scope.
<script src="https://cdn.jsdelivr.net/gh/ucsd-dsm/dsm-web-resources@main/js/dsm_generic/dsm_generic_funcs.min.js"></script>
- Import the script as Javascript module.
<script type="module"> import { testFunc } from 'https://cdn.jsdelivr.net/gh/ucsd-dsm/dsm-web-resources@main/js/dsm_generic/dsm_generic_funcs_module.min.js'; myFunc(); </script>
- Import the script to global scope.
-
Images are stored in the
imgfolder. You can reference the images using the following format.<img src="https://cdn.jsdelivr.net/gh/ucsd-dsm/dsm-web-resources@main/img/logo/logo-abcd-transp.png">