Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Большие перемены (часть 1) #7

Merged
merged 6 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"node": "18"
},
"dependencies": {
"dayjs": "1.11.10"
"dayjs": "1.11.10",
"nanoid": "^5.0.7"
}
}
6 changes: 3 additions & 3 deletions src/const.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const DESTINATION_COUNT = 5;
const POINT_COUNT = 5;
const DESTINATION_COUNT = 7;
const POINTS_COUNT = 9;
const OFFERS_COUNT = 5;
const DEFAULT_TYPE = 'taxi';

Expand Down Expand Up @@ -64,4 +64,4 @@ const FilterType = [{
PAST: 'past'
}];

export {POINT_EMPTY, POINT_TYPE, DESTINATION, DESCRIPTION, OFFERS, DESTINATION_COUNT, OFFERS_COUNT, POINT_COUNT, FilterType};
export {POINT_EMPTY, POINT_TYPE, DESTINATION, DESCRIPTION, OFFERS, DESTINATION_COUNT, OFFERS_COUNT, POINTS_COUNT, FilterType};
2 changes: 1 addition & 1 deletion src/framework/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function render(component, container, place = RenderPosition.BEFOREEND) {
throw new Error('Can render only components');
}

if (container === null) {
if (!container) {
throw new Error('Container element doesn\'t exist');
}

Expand Down
12 changes: 5 additions & 7 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,35 @@ import TripInfoView from './view/trip-info-view.js';
import SortPointsView from './view/sort-points-view.js';
import TripPresenter from './presenter/trip-presenter.js';

import {render, RenderPosition} from './framework/render.js';
import { render, RenderPosition } from './framework/render.js';

import PointsModel from './model/point-model.js';
import DestinationModel from './model/destination-model.js';
import OffersModel from './model/offer-model.js';

import { generateFilters } from './mock/filter.js';


const filterHeaderElement = document.querySelector('.trip-controls');
const siteFilterElement = filterHeaderElement.querySelector('.trip-controls__filters');
const siteMainElement = document.querySelector('.page-main');
const siteSortElement = siteMainElement.querySelector('.trip-events');
const tripInfoElement = document.querySelector('.trip-main');
/* const tripPresenter = new TripPresenter({listContainer: siteSortElement}); */

const pointsModel = new PointsModel();
const destinationModel = new DestinationModel();
const offersModel = new OffersModel();

const tripPresenter = new TripPresenter({
listContainer: siteSortElement,
destinationModel,
offersModel,
pointsModel
pointsModel,
destinationsModel: destinationModel,
offersModel
});

const filters = generateFilters(pointsModel.points);

render(new SortPointsView(), siteSortElement);
render(new FilterPointsView({filters}), siteFilterElement);
render(new FilterPointsView({ filters }), siteFilterElement);
render(new TripInfoView(), tripInfoElement, RenderPosition.AFTERBEGIN);

tripPresenter.init();
136 changes: 124 additions & 12 deletions src/mock/destination.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,132 @@
import { getRandomArrayElement } from '../utils/common';
import { DESTINATION, DESCRIPTION } from '../const';

function getRandomDestination() {
const sity = getRandomArrayElement(DESTINATION);

return {
id: crypto.randomUUID(),
description: DESCRIPTION,
name: sity,
const destinations =
[
{
id: 'fb59a2fb-aaba-48b2-a70f-aeec93f4cf2e',
description: 'Paris - with crowded streets',
name: 'Paris',
pictures: [
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/20.jpg',
description: 'Paris with a beautiful old town'
}
]
},
{
id: 'e58c23c2-364c-4987-a1ca-491b4fd6f2e6',
description: 'Barcelona - is a beautiful city',
name: 'Barcelona',
pictures: [
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/9.jpg',
description: 'Barcelona with crowded streets'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/20.jpg',
description: 'Barcelona with an embankment of a mighty river as a centre of attraction'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/17.jpg',
description: 'Barcelona with an embankment of a mighty river as a centre of attraction'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/9.jpg',
description: 'Barcelona middle-eastern paradise'
}
]
},
{
id: '8cb872d0-b8fa-46d3-bfb2-9f17f41659bc',
description: 'Moscow - a true asian pearl',
name: 'Moscow',
pictures: [
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/7.jpg',
description: 'Moscow with crowded streets'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/9.jpg',
description: 'Moscow is a beautiful city'
}
]
},
{
id: '3593993f-e3cb-41d1-a9ac-966d7d3f238f',
description: 'Berlin - for those who value comfort and coziness',
name: 'Berlin',
pictures: [
{
src:'https://21.objects.htmlacademy.pro/static/destinations/9.jpg',
description: 'Berlin middle-eastern paradise'
}
]
},
{
id: 'bc8d6002-f60b-4196-b3b3-9549b62f323a',
description: 'Amsterdam - full of of cozy canteens where you can try the best coffee in the Middle East',
name: 'Amsterdam',
pictures: [
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/4.jpg',
description: 'Amsterdam a perfect place to stay with a family'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/14.jpg',
description: 'Amsterdam with crowded streets'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/5.jpg',
description: 'Amsterdam a true asian pearl'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/12.jpg',
description: 'Amsterdam a perfect place to stay with a family'
}
]
},
{
id: '49ac16cb-176b-4d14-859c-d230d731811d',
description: 'Rotterdam - famous for its crowded street markets with the best street food in Asia',
name: 'Rotterdam',
pictures: [
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/5.jpg',
description: 'Rotterdam full of of cozy canteens where you can try the best coffee in the Middle East'
}
]
},
{
id: '0496fab3-92ec-43a0-9d3d-c82d17def782',
description: 'Munich - a perfect place to stay with a family',
name: 'Munich',
pictures: [
{
'src': `https://loremflickr.com/248/152?random=${crypto.randomUUID()}`,
'description': `${sity} description`
src: 'https://21.objects.htmlacademy.pro/static/destinations/13.jpg',
description: 'Munich middle-eastern paradise'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/11.jpg',
description: 'Munich in a middle of Europe'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/16.jpg',
description: 'Munich famous for its crowded street markets with the best street food in Asia'
},
{
src: 'https://21.objects.htmlacademy.pro/static/destinations/9.jpg',
description: 'Munich in a middle of Europe'
}
]
};
}
];

function getRandomDestination() {
return getRandomArrayElement(destinations);
}

function getAllDestinations() {
return destinations;
}

export {getRandomDestination};
export {getRandomDestination, getAllDestinations};
Loading
Loading