diff --git a/projects/loft-photo/commentsTemplate.html.hbs b/projects/loft-photo/commentsTemplate.html.hbs new file mode 100644 index 000000000..fd67b84d7 --- /dev/null +++ b/projects/loft-photo/commentsTemplate.html.hbs @@ -0,0 +1,9 @@ +{{#each list}} +
+
+
+
{{name}}
+
{{text}}
+
+
+{{/each}} \ No newline at end of file diff --git a/projects/loft-photo/images/arrow-left.svg b/projects/loft-photo/images/arrow-left.svg new file mode 100644 index 000000000..a4e4c339a --- /dev/null +++ b/projects/loft-photo/images/arrow-left.svg @@ -0,0 +1,4 @@ + + + + diff --git a/projects/loft-photo/images/button.svg b/projects/loft-photo/images/button.svg new file mode 100644 index 000000000..6ce85ea9f --- /dev/null +++ b/projects/loft-photo/images/button.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/projects/loft-photo/images/chat.svg b/projects/loft-photo/images/chat.svg new file mode 100644 index 000000000..fc47d01e1 --- /dev/null +++ b/projects/loft-photo/images/chat.svg @@ -0,0 +1,3 @@ + + + diff --git a/projects/loft-photo/images/exit.svg b/projects/loft-photo/images/exit.svg new file mode 100644 index 000000000..d28c122e1 --- /dev/null +++ b/projects/loft-photo/images/exit.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/projects/loft-photo/images/heart-red.svg b/projects/loft-photo/images/heart-red.svg new file mode 100644 index 000000000..e9985dca6 --- /dev/null +++ b/projects/loft-photo/images/heart-red.svg @@ -0,0 +1,3 @@ + + + diff --git a/projects/loft-photo/images/heart.svg b/projects/loft-photo/images/heart.svg new file mode 100644 index 000000000..4bcdacd80 --- /dev/null +++ b/projects/loft-photo/images/heart.svg @@ -0,0 +1,3 @@ + + + diff --git a/projects/loft-photo/images/logo.svg b/projects/loft-photo/images/logo.svg new file mode 100644 index 000000000..12685673d --- /dev/null +++ b/projects/loft-photo/images/logo.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/projects/loft-photo/images/send.svg b/projects/loft-photo/images/send.svg new file mode 100644 index 000000000..5a55b025c --- /dev/null +++ b/projects/loft-photo/images/send.svg @@ -0,0 +1,3 @@ + + + diff --git a/projects/loft-photo/images/vert1.svg b/projects/loft-photo/images/vert1.svg new file mode 100644 index 000000000..d5d86e658 --- /dev/null +++ b/projects/loft-photo/images/vert1.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/loft-photo/images/vert2.svg b/projects/loft-photo/images/vert2.svg new file mode 100644 index 000000000..0f5e75ed2 --- /dev/null +++ b/projects/loft-photo/images/vert2.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/loft-photo/images/vert3.svg b/projects/loft-photo/images/vert3.svg new file mode 100644 index 000000000..7b481af03 --- /dev/null +++ b/projects/loft-photo/images/vert3.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/loft-photo/index.js b/projects/loft-photo/index.js new file mode 100644 index 000000000..4ab986967 --- /dev/null +++ b/projects/loft-photo/index.js @@ -0,0 +1,11 @@ +import pages from './pages'; +import('./styles.css'); +import mainPage from './mainpage'; +import loginPage from './loginpage'; +const pageNames = ['login', 'main', 'profile']; +import profilePage from './profilepage'; + +pages.openPage('login'); +loginPage.handleEvents(); +mainPage.handleEvents(); +profilePage.handleEvents(); diff --git a/projects/loft-photo/layout.html b/projects/loft-photo/layout.html new file mode 100644 index 000000000..8bb14e8c5 --- /dev/null +++ b/projects/loft-photo/layout.html @@ -0,0 +1,69 @@ + + + + + + Loft Photo + + + +
+ + + +
+ + diff --git a/projects/loft-photo/loginpage.js b/projects/loft-photo/loginpage.js new file mode 100644 index 000000000..9c314ed55 --- /dev/null +++ b/projects/loft-photo/loginpage.js @@ -0,0 +1,15 @@ +import model from './model'; +import pages from './pages'; +import mainPage from './mainpage'; + +export default { + handleEvents() { + document.querySelector('.page-login-button').addEventListener('click', async () => { + await model.login(); + await model.init(); + + pages.openPage('main'); + await mainPage.getNextPhoto(); + }); + }, +}; diff --git a/projects/loft-photo/mainpage.js b/projects/loft-photo/mainpage.js new file mode 100644 index 000000000..c61d29c54 --- /dev/null +++ b/projects/loft-photo/mainpage.js @@ -0,0 +1,117 @@ +import model from './model'; +import profilePage from './profilepage'; +import pages from './pages'; + +import commentsTemplate from './commentsTemplate.html.hbs'; + +export default { + async getNextPhoto() { + const { friend, id, url } = await model.getNextPhoto(); + const stats = await model.photoStats(id); + this.setFriendAndPhoto(friend, id, url, stats); + }, + + setFriendAndPhoto(friend, id, url, stats) { + const photoComp = document.querySelector('.component-photo'); + const headerPhotoComp = document.querySelector('.component-header-photo'); + const headerNameComp = document.querySelector('.component-header-name'); + const footerPhotoComp = document.querySelector('.component-footer-photo'); + + this.friend = friend; + this.photoId = id; + + headerPhotoComp.style.backgroundImage = `url('${friend.photo_50}')`; + headerNameComp.innerText = `${friend.first_name ?? ''} ${friend.last_name ?? ''}`; + photoComp.style.backgroundImage = `url(${url})`; + footerPhotoComp.style.backgroundImage = `url('${model.me.photo_50}')`; + this.setLikes(stats.likes, stats.liked); + this.setComments(stats.comments); + }, + setLikes(total, liked) { + const likes = document.querySelector('.component-footer-container-social-likes'); + likes.innerText = total; + if (liked) { + likes.classList.add('liked'); + } else { + likes.classList.remove('liked'); + } + }, + + setComments(total) { + const comments = document.querySelector( + '.component-footer-container-social-comments' + ); + comments.innerText = total; + }, + + handleEvents() { + let startFrom; + + document.querySelector('.component-photo').addEventListener('touchstart', (e) => { + e.preventDefault(); + startFrom = { y: e.changedTouches[0].pageY }; + }); + document.querySelector('.component-photo').addEventListener('touchend', async (e) => { + e.preventDefault(); + const direction = e.changedTouches[0].pageY - startFrom.y; + if (direction < 0) { + await this.getNextPhoto(); + } + }); + document + .querySelector('.component-header-profile-link') + .addEventListener('click', async () => { + await profilePage.setUser(this.friend); + + pages.openPage('profile'); + }); + document + .querySelector('.component-footer-container-profile-link') + .addEventListener('click', async () => { + await profilePage.setUser(model.me); + pages.openPage('profile'); + }); + document + .querySelector('.component-footer-container-social-likes') + .addEventListener('click', async () => { + const { likes, liked } = await model.like(this.photoId); + this.setLikes(likes, liked); + }); + document + .querySelector('.component-footer-container-social-comments') + .addEventListener('click', async () => { + document.querySelector('.component-comments').classList.remove('hidden'); + await this.loadComments(this.photoId); + }); + const input = document.querySelector('.component-comments-container-form-input'); + document.querySelector('.component-comments').addEventListener('click', async (e) => { + if (e.target === e.currentTarget) { + document.querySelector('.component-comments').classList.add('hidden'); + } + }); + document + .querySelector('.component-comments-container-form-send') + .addEventListener('click', async () => { + if (input.value.trim().length) { + await model.postComment(this.photoId, input.value.trim()); + input.value = ''; + await this.loadComments(this.photoId); + } + }); + }, + async loadComments(photo) { + const comments = await model.getComments(photo); + const commentsElements = commentsTemplate({ + list: comments.map((comment) => { + return { + name: `${comment.user.first_name ?? ''} ${comment.user.last_name ?? ''}`, + photo: comment.user.photo_50, + text: comment.text, + }; + }), + }); + document.querySelector('.component-comments-container-list').innerHTML = ''; + document.querySelector('.component-comments-container-list').append(commentsElements); + this.setComments(comments.length); + }, +}; diff --git a/projects/loft-photo/model.js b/projects/loft-photo/model.js new file mode 100644 index 000000000..f0431a29b --- /dev/null +++ b/projects/loft-photo/model.js @@ -0,0 +1,156 @@ +// VK.init({ +// apiId: 51643234, +// }); + +// function auth() { +// return new Promise((resolve, reject) => { +// VK.Auth.login((data) => { +// if (data.session) { +// resolve(); +// } else { +// reject(new Error('Не удалось авторизоваться')); +// } +// }, 2); +// }); +// } + +// auth().then(() => console.log('ok')); +const PERM_FRIENDS = 2; +const PERM_PHOTOS = 4; + +export default { + async getRandomElement(e) { + if (!e.length) { + return null; + } + const index = Math.round(Math.random() * (e.length - 1)); + return e[index]; + }, + async getNextPhoto() { + const friend = await this.getRandomElement(this.friends.items); + const photos = await this.getFriendPhotos(friend.id); + const photo = await this.getRandomElement(photos.items); + const size = await this.findSize(photo); + return { friend, id: photo.id, url: size.url }; + }, + findSize(photo) { + const size = photo.sizes.find((size) => size.width >= 360); + // if (!size) { + // return photo.sizes.reduce((biggest, current) => { + // if (current.width > biggest.width) { + // return current; + // } + // return biggest; + // }, photo.sizes[0]); + // } + return size; + }, + async init() { + this.photoCache = {}; + this.friends = await this.getFriends(); + [this.me] = await this.getUsers(); + }, + login() { + return new Promise((resolve, reject) => { + VK.init({ + apiId: 51643234, + }); + VK.Auth.login((response) => { + if (response.session) { + this.token = response.session.sid; + resolve(response); + } else { + console.error(response); + reject(response); + } + }, PERM_FRIENDS | PERM_PHOTOS); + }); + }, + logout() {}, + + getUsers(ids) { + const params = { fields: ['photo_50, photo_100'] }; + if (ids) { + params.user_ids = ids; + } + return this.callApi('users.get', params); + }, + callApi(method, params) { + params.v = params.v || 5.131; + + return new Promise((resolve, reject) => { + VK.api(method, params, (response) => { + if (response.error) { + reject(new Error(response.error.error_msg)); + } else { + resolve(response.response); + } + }); + }); + }, + + getFriends() { + const params = { + fields: ['photo_50', 'photo_100'], + }; + + return this.callApi('friends.get', params); + }, + + getPhotos(owner) { + const params = { owner_id: owner }; + return this.callApi('photos.getAll', params); + }, + async getFriendPhotos(id) { + let photos = this.photoCache[id]; + + if (photos) { + return photos; + } + photos = await this.getPhotos(id); + + this.photoCache[id] = photos; + + return photos; + }, + async callServer(method, queryParams, body) { + queryParams = { + ...queryParams, + method, + }; + const query = Object.entries(queryParams) + .reduce((all, [name, value]) => { + all.push(`${name}=${encodeURIComponent(value)}`); + return all; + }, []) + .join('&'); + const params = { + headers: { + vk_token: this.token, + }, + }; + if (body) { + params.method = 'POST'; + params.body = JSON.stringify(body); + } + + const response = await fetch(`/loft-photo/api/?${query}`, params); + + return response.json(); + }, + async like(photo) { + return this.callServer('like', { photo }); + }, + + async photoStats(photo) { + return this.callServer('photoStats', { photo }); + }, + + async getComments(photo) { + return await this.callServer('getComments', { photo }); + }, + + async postComment(photo, text) { + return await this.callServer('postComment', { photo }, { text }); + }, +}; diff --git a/projects/loft-photo/pages.js b/projects/loft-photo/pages.js new file mode 100644 index 000000000..4b9f49ccc --- /dev/null +++ b/projects/loft-photo/pages.js @@ -0,0 +1,19 @@ +const pagesMap = { + login: '.page-login', + main: '.page-main', + profile: '.page-profile', +}; +let page; +export default { + openPage(name) { + const currentClass = pagesMap[name]; + const element = document.querySelector(currentClass); + page?.classList.add('hidden'); + page = element; + page.classList.remove('hidden'); + }, +}; + +// pages.openPage('main'); // сделать видимым элемент с классом page-main +// pages.openPage('profile'); // сделать видимым элемент с классом page-profile, а page-main скрыть +// pages.openPage('login'); // сделать видимым элемент с классом page-login, а page-profile скрыть diff --git a/projects/loft-photo/profilepage.js b/projects/loft-photo/profilepage.js new file mode 100644 index 000000000..e14ca6a19 --- /dev/null +++ b/projects/loft-photo/profilepage.js @@ -0,0 +1,120 @@ +import model from './model'; +import mainPage from './mainpage'; +import pages from './pages'; + +export default { + async setUser(user) { + const photoComp = document.querySelector('.component-user-info-photo'); + const nameComp = document.querySelector('.component-user-info-name'); + const photosTab = document.querySelector('.component-profile-node-photos'); + const friendsTab = document.querySelector('.component-profile-node-friends'); + + this.user = user; + photoComp.style.backgroundImage = `url('${user.photo_100}')`; + nameComp.innerText = `${user.first_name ?? ''} ${user.last_name ?? ''}`; + const node = localStorage.getItem('loft-photo-profile-node') ?? '1'; + + if (node === '1') { + photosTab.click(); + } else { + friendsTab.click(); + } + }, + async showPhotos() { + const photosComp = document.querySelector('.component-user-photos'); + + const photos = await model.getPhotos(this.user.id); + photosComp.innerHTML = ''; + for (const photo of photos.items) { + const size = model.findSize(photo); + const element = document.createElement('div'); + element.classList.add('component-user-photo'); + element.dataset.id = photo.id; + element.style.backgroundImage = `url('${size.url}')`; + photosComp.append(element); + } + }, + async showFriends() { + const friendsComp = document.querySelector('.component-user-friends'); + const friends = await model.getFriends(this.user.id); + + friendsComp.innerHTML = ''; + + for (const friend of friends.items) { + const element = document.createElement('div'); + const photoEl = document.createElement('div'); + const nameEl = document.createElement('div'); + + element.classList.add('component-user-friend'); + element.dataset.id = friend.id; + photoEl.classList.add('component-user-friend-photo'); + photoEl.style.backgroundImage = `url(${friend.photo_100})`; + photoEl.dataset.id = friend.id; + nameEl.classList.add('component-user-friend-name'); + nameEl.innerText = `${friend.first_name ?? ''} ${friend.last_name ?? ''}`; + nameEl.dataset.id = friend.id; + element.append(photoEl, nameEl); + friendsComp.append(element); + } + }, + + handleEvents() { + document + .querySelector('.component-user-photos') + .addEventListener('click', async (e) => { + if (e.target.classList.contains('component-user-photo')) { + const photoId = e.target.dataset.id; + const friendsPhotos = await model.getPhotos(this.user.id); + const photo = friendsPhotos.items.find((photo) => photo.id == photoId); + const size = model.findSize(photo); + const stats = await model.photoStats(photoId); + mainPage.setFriendAndPhoto(this.user, parseInt(photoId), size.url, stats); + + pages.openPage('main'); + } + }); + document + .querySelector('.component-profile-node-photos') + .addEventListener('click', (e) => { + const photosComp = document.querySelector('.component-user-photos'); + const friendsComp = document.querySelector('.component-user-friends'); + photosComp.classList.remove('hidden'); + friendsComp.classList.add('hidden'); + + localStorage.setItem('loft-photo-profile-node', '1'); + this.showPhotos(); + }); + document + .querySelector('.component-profile-node-friends') + .addEventListener('click', (e) => { + const photosComp = document.querySelector('.component-user-photos'); + const friendsComp = document.querySelector('.component-user-friends'); + photosComp.classList.add('hidden'); + friendsComp.classList.remove('hidden'); + + localStorage.setItem('loft-photo-profile-node', '1'); + this.showFriends(); + }); + document + .querySelector('.component-user-friends') + .addEventListener('click', async (e) => { + const friendId = e.target.dataset.id; + if (friendId) { + const [friend] = await model.getUsers([friendId]); + const friendsPhotos = await model.getPhotos(friendId); + const photo = await model.getRandomElement(friendsPhotos.items); + const size = await model.findSize(photo); + const photoStats = await model.photoStats(photo.id); + mainPage.setFriendAndPhoto(friend, parseInt(photo.id), size.url, photoStats); + pages.openPage('main'); + } + }); + document.querySelector('.page-profile-back').addEventListener('click', async () => { + await pages.openPage('main'); + }); + document.querySelector('.page-profile-exit').addEventListener('click', async () => { + await model.logout(); + pages.openPage('login'); + }); + }, +}; diff --git a/projects/loft-photo/server/index.js b/projects/loft-photo/server/index.js new file mode 100644 index 000000000..1ec8bd726 --- /dev/null +++ b/projects/loft-photo/server/index.js @@ -0,0 +1,120 @@ +const http = require('node:http'); +const https = require('node:https'); +const url = require('node:url'); + +const DB = { + tokens: new Map(), + likes: new Map(), + comments: new Map(), +}; + +const methods = { + like(req, res, url, vkUser) { + const photoId = url.searchParams.get('photo'); + let photoLikes = DB.likes.get(photoId); + if (!photoLikes) { + photoLikes = new Map(); + DB.likes.set(photoId, photoLikes); + } + if (photoLikes.get(vkUser.id)) { + photoLikes.delete(vkUser.id); + return { likes: photoLikes.size, liked: false }; + } + photoLikes.set(vkUser.id, true); + return { likes: photoLikes.size, liked: true }; + }, + photoStats(req, res, url, vkUser) { + const photoId = url.searchParams.get('photo'); + const photoLikes = DB.likes.get(photoId); + const photoComments = DB.comments.get(photoId); + return { + likes: photoLikes?.size ?? 0, + liked: photoLikes?.has(vkUser.id) ?? false, + comments: photoComments?.length ?? 0, + }; + }, + postComment(req, res, url, vkUser, body) { + const photoId = url.searchParams.get('photo'); + let photoComments = DB.comments.get(photoId); + if (!photoComments) { + photoComments = []; + DB.comments.set(photoId, photoComments); + } + photoComments.unshift({ user: vkUser, text: body.text }); + }, + getComments(req, res, url) { + const photoId = url.searchParams.get('photo'); + return DB.comments.get(photoId) ?? []; + }, +}; + +http + .createServer(async (req, res) => { + console.log('➡️ Поступил запрос:', req.method, req.url); + const token = req.headers['vk_token']; + const parsed = new url.URL(req.url, 'http://localhost'); + const vkUser = await getMe(token); + const body = await readBody(req); + const responseData = await methods[parsed.searchParams.get('method')]?.( + req, + res, + parsed, + vkUser, + body + ); + res.end(JSON.stringify(responseData ?? null)); + }) + .listen('8888', () => { + console.log('🚀 Сервер запущен'); + }); + +async function readBody(req) { + if (req.method === 'GET') { + return null; + } + + return new Promise((resolve) => { + let body = ''; + req + .on('data', (chunk) => { + body += chunk; + }) + .on('end', () => resolve(JSON.parse(body))); + }); +} + +async function getVKUser(token) { + const body = await new Promise((resolve, reject) => + https + .get( + `https://api.vk.com/method/users.get?access_token=${token}&fields=photo_50&v=5.120` + ) + .on('response', (res) => { + let body = ''; + + res.setEncoding('utf8'); + res + .on('data', (chunk) => { + body += chunk; + }) + .on('end', () => resolve(JSON.parse(body))); + }) + .on('error', reject) + ); + + return body.response[0]; +} + +async function getMe(token) { + const existing = DB.tokens.get(token); + + if (existing) { + return existing; + } + + const user = getVKUser(token); + + DB.tokens.set(token, user); + + return user; +} diff --git a/projects/loft-photo/settings.json b/projects/loft-photo/settings.json new file mode 100644 index 000000000..3d20b4405 --- /dev/null +++ b/projects/loft-photo/settings.json @@ -0,0 +1,7 @@ +{ + "proxy": { + "/loft-photo/api/": { + "target": "http://localhost:8888" + } + } +} diff --git a/projects/loft-photo/styles.css b/projects/loft-photo/styles.css new file mode 100644 index 000000000..a4dbc2eeb --- /dev/null +++ b/projects/loft-photo/styles.css @@ -0,0 +1,382 @@ +/* base */ + +body { + font-family: 'Roboto Light', Geneva, Arial, Helvetica, sans-serif; +} + +.hidden { + display: none !important; +} + +a { + text-decoration: none; +} + +/* app */ + +#app { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + display: flex; + + align-items: center; + justify-content: center; +} + +.page { + height: 100%; + width: 360px; + position: relative; +} + +/* page login */ + +.page-login { + display: flex; + justify-content: center; + background: #1c1b1f; +} + +.page-login-button { + border: none; + background: url('images/button.svg'); + width: 219px; + height: 40px; + position: absolute; + bottom: 60px; + margin: 0 auto; +} + +.page-login-logo { + top: 429px; + position: absolute; + gap: 16px; + display: flex; + flex-direction: column; + align-items: center; +} + +.page-login-image { + width: 147px; + height: 24px; + background: url('images/logo.svg'); +} + +.page-login-text { + font-size: 14px; + line-height: 20px; + text-align: center; + width: 237px; + color: #b0b0b0; +} + +.page-login-vert1, +.page-login-vert2, +.page-login-vert3 { + width: 71px; + height: 333px; + position: absolute; +} + +.page-login-vert1 { + top: 59px; + left: 49px; + background: linear-gradient(180deg, rgba(28, 27, 31, 0) 80%, #1c1b1f 100%), + url('images/vert1.svg'); +} + +.page-login-vert2 { + top: 81px; + left: 144px; + background: linear-gradient(180deg, rgba(28, 27, 31, 0) 80%, #1c1b1f 100%), + url('images/vert2.svg'); +} + +.page-login-vert3 { + top: 59px; + left: 239px; + background: linear-gradient(180deg, rgba(28, 27, 31, 0) 80%, #1c1b1f 100%), + url('images/vert3.svg'); +} + +/* page main */ + +.page-main .component-header { + position: absolute; + display: flex; + height: 80px; + top: 0; + left: 0; + right: 0; + background: rgba(0 0 0 / 25%); + padding: 0 24px; +} + +.page-main .component-header-profile-link { + display: flex; + align-items: center; +} + +.page-main .component-header-photo { + width: 40px; + height: 40px; + border-radius: 50%; + flex-shrink: 0; +} + +.page-main .component-header-name { + margin-left: 8px; + font-weight: 400; + font-size: 16px; + color: white; +} + +.page-main .component-footer { + position: absolute; + display: flex; + height: 80px; + bottom: 0; + left: 0; + right: 0; + background: rgba(0 0 0 / 25%); + padding: 0 24px; +} + +.page-main .component-footer-container { + display: flex; + align-items: center; + width: 100%; +} + +.page-main .component-footer-container-profile-link { + margin-left: auto; +} + +.page-main .component-footer-photo { + width: 40px; + height: 40px; + border-radius: 50%; +} + +.page-main .component-footer-container-social-comments, +.page-main .component-footer-container-social-likes { + color: white; + display: flex; + align-items: center; +} + +.page-main .component-footer-container-social-comments:before, +.page-main .component-footer-container-social-likes:before { + display: inline-block; + content: ''; + width: 20px; + height: 20px; + margin-right: 6px; +} + +.page-main .component-footer-container-social-comments:before { + background: url('images/chat.svg'); +} + +.page-main .component-footer-container-social-likes:before { + background: url('images/heart.svg'); + margin-left: 18px; +} + +.page-main .component-footer-container-social-likes.liked:before { + background: url('images/heart-red.svg'); + margin-left: 18px; +} + +.page-main .component-photo { + height: 100%; + width: 360px; + position: relative; + + background-size: cover; + background-position: center; +} + +.component-comments { + position: fixed; + bottom: 0; + left: 0; + right: 0; + top: 0; + background: rgba(0, 0, 0, 0.4); +} + +.component-comments-container { + position: absolute; + display: flex; + flex-direction: column; + top: 50vh; + bottom: 0; + left: 0; + right: 0; + padding: 16px; + border-radius: 28px 28px 0 0; + background: white; +} + +.component-comments-container-title { + font-size: 14px; + text-align: center; + width: 100%; +} + +.component-comments-container-list { + margin-top: 24px; + flex-grow: 1; + display: flex; + gap: 12px; + flex-direction: column; + overflow-y: auto; + margin-bottom: 14px; +} + +.component-comments-container-form { + display: flex; + align-items: center; + gap: 16px; + height: 48px; +} + +.component-comments-container-form-input { + box-sizing: border-box; + border: 1px solid #e0e0e0; + border-radius: 32px; + flex-grow: 1; + height: 48px; +} + +.component-comments-container-form-input, +.component-comments-container-form-input, +.component-comments-container-form-input, +.component-comments-container-form-input { + padding: 14px 16px; +} + +.component-comments-container-form-send { + background: url('images/send.svg'); + width: 40px; + height: 40px; +} + +.component-comment { + display: flex; + gap: 8px; +} + +.component-comment-photo { + width: 24px; + height: 24px; + border-radius: 50%; + background-position: center; + background-size: cover; +} + +.component-comment-content { + flex-direction: column; +} + +.component-comment-name { + font-size: 12px; +} + +.component-comment-text { + font-size: 14px; +} + +/* page profile */ + +.page-profile { + margin-top: 52px; +} + +.page-profile-back { + background: url('images/arrow-left.svg'); + width: 24px; + height: 24px; + + position: absolute; + left: 24px; +} + +.page-profile-exit { + background: url('images/exit.svg'); + width: 24px; + height: 24px; + + position: absolute; + right: 24px; +} + +.component-user-photos { + display: flex; + flex-wrap: wrap; + gap: 8px; + padding: 24px 16px 16px 16px; +} + +.component-user-photo { + width: 104px; + height: 104px; + background-size: cover; + background-repeat: no-repeat; + background-position: center; +} + +.page-profile .component-user-info { + display: flex; + flex-direction: column; + align-items: center; +} + +.page-profile .component-user-info-photo { + height: 72px; + width: 72px; + border-radius: 50%; + + background-size: cover; + background-position: center; +} + +.page-profile .component-user-info-name { + font-weight: 400; + font-size: 18px; + line-height: 26px; + margin-top: 8px; +} +.component-profile-node { + display: flex; + justify-content: center; + text-decoration: underline; + margin-bottom: 20px; +} +.component-profile-node-photos { + margin-right: 10px; +} +.component-user-friend { + margin-right: 15px; + cursor: pointer; +} +.component-user-friends { + display: flex; + align-items: center; + justify-content: center; + flex-wrap: wrap; +} +.component-user-friend-name { + text-align: center; + width: 100px; + margin-bottom: 20px; +} +.component-user-friend-photo { + width: 100px; + height: 100px; + border-radius: 50%; +} diff --git a/webpack.config.js b/webpack.config.js index 2c7806598..433fc4470 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -61,7 +61,8 @@ module.exports = { options: { cacheDirectory: true }, }, { - test: /projects\/.+\.html$/, + test: /\.html$/, + include: [path.join(__dirname, 'projects')], use: [{ loader: './scripts/html-inject-loader.js' }, { loader: 'html-loader' }], }, {