Setup
Install Sass:
npm install -g sass
Install Typescript:
npm install -g typescript
Compile and run a single file
tsc sample.ts
This will compile a single Typescript file into a Javascript file.
node sample.js
Next, you can run thw generated Javascript file using NodeJs.
Running
The command below will compile all .scss
files from the ./sass
folder and put it inside the ./css
folder as .css
files.
sass --watch sass:css
The command bellow will compile all .ts
files inside the ./ts
folder and put it inside the ./js
folder as .js
files.
tsc -w
Follow the steps below in order to create your own page on The Design Web.
- Fork this repo to your own GitHub account
- Clone the repo
- Run the
sass
command above to compile the CSS assets. - Create a new folder with the name of your styling and design guidelines, be creative in this one. Note: Replace spaces with a dash (-).
- Inside your folder create an
index.html
file. - Inside the sass folder create a file named
<your-styleguide-name>.scss
. - Reference the
.css
equivalent inside yourindex.html
file. - Add your page to the
main.ts
file. - Compile the typescript files.
- Most important step: Design your styleguide, have fun with this!
- When finished, checkout to a new branch with git.
- Push the the changes to your new branch.
- Go to the forked repo on GitHub, on your account.
- Create a new pull request to merge with the main repository.
- Wait unitl the owner approves your request.
- See your changes live on the Website.
Let's practice your Typescript skills!
Exercise
- Create a new file inside the
./ts
folder, name it<your-styleguide-name>.ts
. - Reference the JavaSript equivalent of this file inside your
index.html
file.
Create a Typescript interface
or type
called Counter
with the following attributes:
- Counter of type
number
which represents the current state of the counter - Name of type
string
which holds the name or title what the counter is counting for - Steps of type
number
this holds the number of how fast the counter should increment or decrement - Pointer of type
boolean
if the pointer istrue
then the counter will increment, else decrement. - Freeze of type
boolean
this is a bonus functionality to make the counter stop counting
The interface has the following methods:
Increment(): void
, which increments the counter by the given steps.Decrement(): void
, which decrements the counter by the given steps.Faster(): void
, this will make the counter count faster, by incrementing the steps attribute.SlowDown(): void
, this will make the counter count slower.StopTheTime(): void
, this will make the counter stop counting.
Next implement the interface by using a const
.
If you have implemented all the methods then show the counter state on an HTML page. Where all of the methods are mapped to a button and the actions are invoked when the user clicks on a button.
Can you create a counter that counts automatically with a given time interval?
Can you React?
If you are done with the plain HTML implementation can you build a version using React? https://react.dev/ What are the main differences? To what problem does React provide a solution?