diff --git a/src/consts.js b/src/consts.js new file mode 100644 index 0000000..a00b7f1 --- /dev/null +++ b/src/consts.js @@ -0,0 +1,3 @@ +const POINT_COUNT = 3; + +export {POINT_COUNT}; diff --git a/src/main.js b/src/main.js index e69de29..c2f8e84 100644 --- a/src/main.js +++ b/src/main.js @@ -0,0 +1,12 @@ +import FilterView from './view/filter-view.js'; +import SortView from './view/sort-view.js'; +import ListPresenter from './presenter/list-presenter.js'; +import {render} from './render.js'; + +const filterContainer = document.querySelector('.trip-controls__filters'); +const sortAndListContainer = document.querySelector('.trip-events'); +const listPresenter = new ListPresenter({container: sortAndListContainer}); + +render(new FilterView(), filterContainer); +render(new SortView(), sortAndListContainer); +listPresenter.init(); diff --git a/src/presenter/list-presenter.js b/src/presenter/list-presenter.js new file mode 100644 index 0000000..5f0ad30 --- /dev/null +++ b/src/presenter/list-presenter.js @@ -0,0 +1,22 @@ +import {POINT_COUNT} from '../consts.js'; +import ListView from '../view/list-view.js'; +import EditPointView from '../view/edit-point-view.js'; +import ListPointView from '../view/list-point-view.js'; +import {render} from '../render.js'; + +export default class ListPresenter { + listComponent = new ListView(); + + constructor({container}) { + this.container = container; + } + + init() { + render(this.listComponent, this.container); + render(new EditPointView(), this.listComponent.getElement()); + + for (let i = 0; i < POINT_COUNT; i++) { + render(new ListPointView(), this.listComponent.getElement()); + } + } +} diff --git a/src/view/add-new-point-view.js b/src/view/add-new-point-view.js new file mode 100644 index 0000000..9996696 --- /dev/null +++ b/src/view/add-new-point-view.js @@ -0,0 +1,186 @@ +import {createElement} from '../render.js'; + +function createNewPointTemplate() { + return ` +
  • +
    +
    +
    + + + +
    +
    + Event type + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    +
    +
    + +
    + + + + + + + +
    + +
    + + + — + + +
    + +
    + + +
    + + + +
    +
    +
    +

    Offers

    + +
    +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    +
    + +
    +

    Destination

    +

    Geneva is a city in Switzerland that lies at the southern tip of expansive Lac LĂ©man (Lake Geneva). Surrounded by the Alps and Jura mountains, the city has views of dramatic Mont Blanc.

    + +
    +
    + Event photo + Event photo + Event photo + Event photo + Event photo +
    +
    +
    +
    +
    +
  • + `; +} + +export default class AddNewPointView { + getTemplate() { + return createNewPointTemplate(); + } + + getElement() { + if (!this.element) { + this.element = createElement(this.getTemplate()); + } + + return this.element; + } + + removeElement() { + this.element = null; + } +} diff --git a/src/view/edit-point-view.js b/src/view/edit-point-view.js new file mode 100644 index 0000000..bfc75ff --- /dev/null +++ b/src/view/edit-point-view.js @@ -0,0 +1,179 @@ +import {createElement} from '../render'; + +function createEditPointTemplate() { + return ` +
  • +
    +
    +
    + + + +
    +
    + Event type + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    +
    +
    + +
    + + + + + + + +
    + +
    + + + — + + +
    + +
    + + +
    + + + + +
    +
    +
    +

    Offers

    + +
    +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    +
    + +
    +

    Destination

    +

    Chamonix-Mont-Blanc (usually shortened to Chamonix) is a resort area near the junction of France, Switzerland and Italy. At the base of Mont Blanc, the highest summit in the Alps, it's renowned for its skiing.

    +
    +
    +
    +
  • + `; +} + +export default class EditPointView { + getTemplate() { + return createEditPointTemplate(); + } + + getElement() { + if (!this.element) { + this.element = createElement(this.getTemplate()); + } + + return this.element; + } + + removeElement() { + this.element = null; + } +} diff --git a/src/view/filter-view.js b/src/view/filter-view.js new file mode 100644 index 0000000..e461319 --- /dev/null +++ b/src/view/filter-view.js @@ -0,0 +1,47 @@ +import {createElement} from '../render.js'; + +function createFilterTemplate() { + return ` +
    +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + + +
    + `; +} + +export default class FilterView { + getTemplate() { + return createFilterTemplate(); + } + + getElement() { + if (!this.element) { + this.element = createElement(this.getTemplate()); + } + + return this.element; + } + + removeElement() { + this.element = null; + } +} diff --git a/src/view/list-point-view.js b/src/view/list-point-view.js new file mode 100644 index 0000000..f3b585e --- /dev/null +++ b/src/view/list-point-view.js @@ -0,0 +1,66 @@ +import {createElement} from '../render.js'; + +function createListPointTemplate() { + return ` +
  • +
    + +
    + Event type icon +
    +

    Flight Chamonix

    +
    +

    + + — + +

    +

    01H 10M

    +
    +

    + € 160 +

    +

    Offers:

    + + + +
    +
  • + `; +} + +export default class ListPointView { + getTemplate() { + return createListPointTemplate(); + } + + getElement() { + if (!this.element) { + this.element = createElement(this.getTemplate()); + } + + return this.element; + } + + removeElement() { + this.element = null; + } +} diff --git a/src/view/list-view.js b/src/view/list-view.js new file mode 100644 index 0000000..49f1c03 --- /dev/null +++ b/src/view/list-view.js @@ -0,0 +1,23 @@ +import {createElement} from '../render.js'; + +function createListTemplate() { + return ''; +} + +export default class ListView { + getTemplate() { + return createListTemplate(); + } + + getElement() { + if (!this.element) { + this.element = createElement(this.getTemplate()); + } + + return this.element; + } + + removeElement() { + this.element = null; + } +} diff --git a/src/view/sort-view.js b/src/view/sort-view.js new file mode 100644 index 0000000..bd38720 --- /dev/null +++ b/src/view/sort-view.js @@ -0,0 +1,50 @@ +import {createElement} from '../render'; + +function createSortTemplate() { + return ` +
    +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    + `; +} + +export default class SortView { + getTemplate() { + return createSortTemplate(); + } + + getElement() { + if (!this.element) { + this.element = createElement(this.getTemplate()); + } + + return this.element; + } + + removeElement() { + this.element = null; + } +}