diff --git a/src/main.js b/src/main.js index e69de29..0efd436 100644 --- a/src/main.js +++ b/src/main.js @@ -0,0 +1,13 @@ +import TripInfoView from './view/trip-info-view.js'; +import FilterView from './view/filter-view.js'; +import { render, RenderPosition } from './render.js'; +import TripPresenter from './presenter/trip-presenter.js'; + +const tripInfoElement = document.querySelector('.trip-main'); +const siteMainElement = document.querySelector('.page-main'); +const tripPresenter = new TripPresenter(siteMainElement.querySelector('.trip-events')); + +render(new TripInfoView(), tripInfoElement, RenderPosition.AFTERBEGIN); +render(new FilterView(), tripInfoElement.querySelector('.trip-controls__filters')); + +tripPresenter.init(); \ No newline at end of file diff --git a/src/presenter/trip-presenter.js b/src/presenter/trip-presenter.js new file mode 100644 index 0000000..7fb15c8 --- /dev/null +++ b/src/presenter/trip-presenter.js @@ -0,0 +1,22 @@ +import SortView from '../view/sort-view.js'; +import EditPointView from '../view/edit-point-view.js'; +import PointView from '../view/point-view.js'; +import TripView from '../view/point-list-view.js'; +import { render } from '../render.js'; + +export default class TripPresenter { + constructor(tripContainer) { + this.tripContainer = tripContainer; + this.pointList = new TripView(); + } + + init() { + render(new SortView(), this.tripContainer); + render(this.pointList, this.tripContainer); + render(new EditPointView(), this.pointList.getElement()); + + for (let i = 0; i < 3; i++) { + render(new PointView(), this.pointList.getElement()); + } + } +} \ No newline at end of file diff --git a/src/view/edit-point-view.js b/src/view/edit-point-view.js new file mode 100644 index 0000000..e58867c --- /dev/null +++ b/src/view/edit-point-view.js @@ -0,0 +1,186 @@ +import { createElement } from '../render.js'; + +const createEditPointTemplate = () => { + 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 EditPointView { + getTemplate() { + return createEditPointTemplate(); + } + + getElement() { + if (!this.element) { + this.element = createElement(this.getTemplate()); + } + + return this.element; + } + + removeElement() { + this.element = null; + } +} \ No newline at end of file diff --git a/src/view/filter-view.js b/src/view/filter-view.js new file mode 100644 index 0000000..3044dd3 --- /dev/null +++ b/src/view/filter-view.js @@ -0,0 +1,43 @@ +import { createElement } from '../render.js'; + +const 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; + } +} \ No newline at end of file diff --git a/src/view/point-list-view.js b/src/view/point-list-view.js new file mode 100644 index 0000000..08670f1 --- /dev/null +++ b/src/view/point-list-view.js @@ -0,0 +1,25 @@ +import { createElement } from '../render.js'; + +const createPointListTemplate = () => { + return ( + `