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
export class HttpClient { | |
get(url) { | |
return fetch(url).then(response => response.json()); | |
} | |
} |
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
$space-unit: 16px; | |
$spacer-xxs : round($space-unit * .25); // 4px | |
$spacer-xs : round($space-unit * .5); // 8px | |
$spacer-sm : round($space-unit * .75); // 12px | |
$spacer-md : round($space-unit * 1.25); // 20px | |
$spacer-lg : round($space-unit * 2); // 32px | |
$spacer-xl : round($space-unit * 3.25); // 52px | |
$spacer-xxl : round($space-unit * 5.25); // 84px |
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
class ProdutoDesconto extends Produto { | |
constructor(nome, preco, desconto) { | |
super(nome, preco); | |
this.desconto = desconto; | |
} | |
salvar(storage) { | |
const comDesconto = { nome: this.nome, preco: this.preco - (this.preco * this.desconto) }; | |
storage.store(comDesconto); | |
return storage.length; |
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
const produtos = [ | |
{ nome: 'ProdutoA', preco: 28.90 }, | |
{ nome: 'ProdutoB', preco: 34.40 }, | |
{ nome: 'ProdutoC', preco: 149.90, desconto: 0.2 } | |
]; |
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
function insereTodos(produtos) { | |
const storage = new ProdutoStorage(); //{1} | |
for (let p of produtos) { //{2} | |
let produto; | |
if (p.desconto) { | |
produto = new ProdutoDesconto(p.nome, p.preco, p.desconto); | |
} else { | |
produto = new Produto(p.nome, p.preco); | |
} |
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
class ProdutoStorage { | |
constructor() { | |
this.produtos = []; | |
} | |
get length() { | |
return this.produtos.length; | |
} | |
store(produto) { |
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
class ProdutoDesconto extends Produto { | |
constructor(nome, preco, desconto) { | |
super(nome, preco); | |
this.desconto = desconto; | |
} | |
salvar(storage) { | |
const comDesconto = { nome: this.nome, preco: this.preco - (this.preco * this.desconto) }; | |
storage.store(comDesconto); | |
return comDesconto; |
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
class Produto { | |
constructor(nome, preco) { | |
this.nome = nome; | |
this.preco = preco; | |
} | |
salvar(storage) { | |
storage.store({ nome: this.nome, preco: this.preco }); | |
return storage.length; | |
} |
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
class List extends Component { | |
constructor(items) { | |
super(); | |
this._items = items; | |
} | |
// getters/setters ... | |
render(element) { | |
element.innerHTML = ` |
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
class Card extends Component { | |
constructor(description) { | |
super(); | |
this._description = description; | |
} | |
// getters/setters ... | |
render(element) { | |
element.innerHTML = ` |