Skip to content

Commit bf8fc60

Browse files
committed
1 parent 015ea99 commit bf8fc60

File tree

10 files changed

+464
-0
lines changed

10 files changed

+464
-0
lines changed
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Cowsay
2+
3+
Do you remember [Cowsay](https://github.com/CodeYourFuture/JavaScript-Core-1-Challenges)? We learned about node packages and made a cow say stuff. Now, we know more about programming, let's figure out how to make a cow say things in Node by ourselves.
4+
5+
## Project
6+
7+
For this project we don't need a package, a library or lots of options. Let's just get our own cow printing out and saying whatever we write in the command line. What would be helpful? I think we need to:
8+
9+
- [Accept an argument](https://nodejs.dev/learn/nodejs-accept-arguments-from-the-command-line) from the command line.
10+
- Output to the command line. You've already done this with console.log.
11+
- Make an ASCII cow.
12+
- Write a function that puts the string into the cow's speech bubble.
13+
14+
Write your solution in the file solution1.js and test it by running your program in the command line. How will you handle it when no argument is given? How will you make the picture of a cow?
15+
16+
### Iterating
17+
18+
We could make our program more accessible by adding a command line interface that prompts us to write in the cow's words. What tools can we use? I think we could use:
19+
20+
- A command line interface. I'll start you off by letting you know that there is a built in CLI called [readline](https://nodejs.dev/learn/accept-input-from-the-command-line-in-nodejs).
21+
- Our ASCII cow again.
22+
- And our cow function.
23+
24+
Write your solution in a file called solution2.js and test it by running your program in the command line. Use a prompt to ask for your cow saying.
25+
26+
Compare your approach to the sample solutions (you can unlock next week). Your solution might be different and that's ok. If you can print a cow and you can make it say different things, you solved it.
27+
28+
A slightly simpler ASCII cow that might help if you hit formatting issues.
29+
30+
```
31+
/
32+
/
33+
^__^ /
34+
(oo)'_______
35+
(__) )-~
36+
||----w |
37+
|| ||
38+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// =================
2+
// Stripped down cowsayer CLI,
3+
// no libraries
4+
// https://nodejs.dev/learn/nodejs-accept-arguments-from-the-command-line
5+
// =================
6+
7+
// 1. Accept arguments
8+
9+
// how will you accept arguments?
10+
11+
// 2. Make supplies for our speech bubble
12+
13+
let topLine = '_';
14+
let bottomLine = '-';
15+
let saying = '';
16+
17+
// 3. Make a cow that takes a string
18+
19+
function cowsay(saying) {
20+
// how will you make the speech bubble contain the text?
21+
22+
// where will the cow picture go?
23+
24+
// how will you account for the parameter being empty?
25+
26+
}
27+
28+
//4. Pipe argument into cowsay function and return a cow
29+
30+
// how will you log this to the console?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// =================
2+
// Stripped down cowsayer CLI,
3+
// no libraries or arguments
4+
// https://nodejs.dev/learn/accept-input-from-the-command-line-in-nodejs
5+
// =================
6+
7+
// 1. Make a command line interface.
8+
9+
// 2. Make supplies for our speech bubble
10+
11+
// 3. Make a cow that takes a string
12+
13+
const cow = (saying) => {
14+
// how did you make the cow before?
15+
}
16+
17+
// 4. Use readline to get a string from the terminal
18+
// (with a prompt so it's clearer what we want)
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Mini-weather
2+
3+
![Screenshot](assets/meteoropolis.png)
4+
5+
[Click here for live demo](https://mini-weatherapp.herokuapp.com/)
6+
7+
This app blends data from [openweathermap.org](https://openweathermap.org/) and
8+
[Unsplash](https://unsplash.com/developers) to create a visual depiction of the current weather in your area.
9+
10+
## Set-up
11+
12+
- Fork and clone the repo
13+
14+
- You will need to sign up for both services to get an API key to use each service.
15+
16+
- **Open Weather** - sign up for API key at [https://openweathermap.org/appid](https://openweathermap.org/appid) and append it to URL as `APPID` URL parameter. For example, `http://api.openweathermap.org/data/2.5/weather?q=london&APPID=ABC` where `ABC` is the API key you were provided.
17+
- **Unsplash** - sign up for Unsplash at [https://unsplash.com/join](https://unsplash.com/join) and register your app. You will receive an Access Key which you should append it to the URL as `client_id` URL param. For example, `https://api.unsplash.com/search/photos?query=snow&client_id=XYZ` where `XYZ` is your Access Key.
18+
19+
- The base HTML and CSS have been supplied if you wish to focus on the programming and not the UI, but you should feel free to customise your application as you see fit. You can insert the main photo into the element with the id `photos` and thumbnails into the element with id `thumbs`. Use developer tools to inspect the structure of HTML in working example to get a sense of what it required.
20+
21+
## Objectives
22+
23+
- [ ] Use `fetch` to retrieve the weather for a single day. You can see the documentation at [https://openweathermap.org/current](https://openweathermap.org/current). For now, we'll set London or another location of your choice as the default.
24+
25+
- [ ] Once you've retrieved the weather data, use its `description` property to get matching images from Unsplash. You can see the documentation for image search at [https://unsplash.com/documentation#search-photos](https://unsplash.com/documentation#search-photos).
26+
27+
- [ ] Display the images as a gallery of clickable thumbnails (clicking loads the main image)
28+
29+
- [ ] Commit code regularly, push and create a pull request so we can see how you got on
30+
31+
## Stretch goals
32+
33+
- [ ] Use the input field that lets us see what the weather is like in other cities
34+
35+
- [ ] Add a feature of your choice
36+
37+
- [ ] Display photographer credits in bottom right hand corner with link to their portfolio on Unsplash
38+
39+
- [ ] Display white border around thumbnail of image currently displayed as main image using `active` class
40+
41+
You may need to use data attributes as part of the exercise. You can see more info about them at [https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@keyframes fade-in {
2+
to {
3+
opacity: 1;
4+
}
5+
}
6+
7+
*,
8+
*::before,
9+
*::after {
10+
box-sizing: inherit;
11+
}
12+
13+
:root {
14+
--thumb-w: 80px;
15+
--thumb-h: 45px;
16+
--thumbs-px: 10px;
17+
--thumbs-py: 10px;
18+
--thumbs-h: calc(var(--thumb-h) + (var(--thumbs-py) * 2));
19+
}
20+
21+
html,
22+
body {
23+
height: 100%;
24+
}
25+
26+
html {
27+
box-sizing: border-box;
28+
}
29+
30+
body {
31+
transition: 1s background-color;
32+
33+
overflow: hidden;
34+
margin: 0;
35+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
36+
Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
37+
font-size: 14px;
38+
background: center center no-repeat;
39+
background-size: contain;
40+
color: #333;
41+
}
42+
43+
a {
44+
color: inherit;
45+
text-decoration: none;
46+
}
Loading

0 commit comments

Comments
 (0)