Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
nurgeldiserikbay committed Mar 25, 2024
0 parents commit 36194b3
Show file tree
Hide file tree
Showing 40 changed files with 1,593 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_BASE_URL=https://www.thecocktaildb.com/api/json/v1
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "always",
"useTabs": true,
"tabWidth": 2
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

## Recommended Setup

- [VS Code](https://code.visualstudio.com/) + [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously Volar) and disable Vetur

- Use [vue-tsc](https://github.com/vuejs/language-tools/tree/master/packages/tsc) for performing the same type checking from the command line, or for generating d.ts files for SFCs.
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Simurg Test</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "simurg-test",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.6.8",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"vue": "^3.4.21",
"vue-router": "^4.3.0",
"vue3-lazyload": "^0.3.8"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"sass": "^1.72.0",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vue-tsc": "^2.0.6"
}
}
9 changes: 9 additions & 0 deletions src/app/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<div>
<router-view />
</div>
</template>

<script setup lang="ts"></script>

<style scoped></style>
19 changes: 19 additions & 0 deletions src/app/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { createApp } from 'vue'
import App from '@/app/App.vue'
import { router, setupRouter } from '@/app/router'
import { setupStore } from '@/shared/stores'
import { registerModules } from '@/app/providers/register-modules'
import VueLazyLoad from 'vue3-lazyload'

import '@/app/styles/style.scss'

export function init() {
const app = createApp(App)

app.use(VueLazyLoad, {})

setupStore(app)
registerModules(router)
setupRouter(app)
app.mount('#app')
}
10 changes: 10 additions & 0 deletions src/app/plugins/axios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import axios, { type AxiosInstance } from 'axios'

const api: AxiosInstance = axios.create({
baseURL: import.meta.env.VITE_BASE_URL,
headers: {
'Content-type': 'application/json',
},
})

export default api
21 changes: 21 additions & 0 deletions src/app/providers/register-modules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Router } from 'vue-router'
import type { DefaultModule } from '@/shared/types/common'

interface AppModule {
router?: (router: Router) => void
}

const modules = import.meta.glob<DefaultModule<AppModule>>(
'@/modules/*/index.ts',
)

export function registerModules(router: Router) {
const registerModule = (module: AppModule) => {
if (module.router) module.router(router)
}

Object.keys(modules).forEach(async (moduleKey) => {
const module = await modules[moduleKey]()
registerModule(module.default)
})
}
13 changes: 13 additions & 0 deletions src/app/router/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { App } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import { routes } from './routes'

export const router = createRouter({
history: createWebHistory(),
routes,
linkActiveClass: 'active',
})

export function setupRouter(app: App) {
app.use(router)
}
1 change: 1 addition & 0 deletions src/app/router/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const routes = []
1 change: 1 addition & 0 deletions src/app/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "./styles/index.scss";
5 changes: 5 additions & 0 deletions src/app/styles/_global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.head-3 {
font-weight: bold;
font-size: 18px;
line-height: 1.4;
}
20 changes: 20 additions & 0 deletions src/app/styles/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@function join-list($list, $separator: ", ") {
$result-string: "";

@each $item in $list {
$index: index($list, $item);
$result-string: $result-string + $item;

@if ($index !=length($list)) {
$result-string: $result-string + $separator;
}
}

@return $result-string;
}

@mixin get-media($medias...) {
@media #{join-list($medias)} {
@content;
}
}
13 changes: 13 additions & 0 deletions src/app/styles/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Media
$fullhd-width: 1560px;
$desktop-width: 1281px;
$laptop-width: 1025px;
$tablet-width: 768px;
$mobile-width: 280px;

// Media queries as strings
$fullhd: "(min-width: #{$fullhd-width})";
$desktop: "(min-width: #{$desktop-width})";
$laptop: "(min-width: #{$laptop-width}) and (max-width: #{$desktop-width - 1})";
$tablet: "(min-width: #{$tablet-width}) and (max-width: #{$laptop-width - 1})";
$mobile: "(max-width: #{$tablet-width - 1})";
11 changes: 11 additions & 0 deletions src/app/styles/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@import 'global.scss';
@import 'mixins.scss';
@import 'variables.scss';

html,
body {
height: 100%;
margin: 0;
padding: 0;
min-height: 100%;
}
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { init } from '@/app/app'

init()
68 changes: 68 additions & 0 deletions src/modules/cocktails/components/CocktailList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<div class="cocktail-list">
<router-link
v-for="cocktail in cocktailStore._getCocktailList"
:key="cocktail.slug"
:to="`/${cocktail.slug}`"
class="cocktail-list__item"
>
{{ cocktail.name }}
</router-link>
</div>
</template>

<script setup lang="ts">
import { onBeforeMount } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useCocktailStore } from '../store'
const $route = useRoute()
const $router = useRouter()
const cocktailStore = useCocktailStore()
onBeforeMount(async () => {
await cocktailStore._fetchCocktailList()
if (!$route.params.slug) {
$router.push(`/${cocktailStore._getCocktailList[0].slug}`)
}
})
</script>

<style lang="scss" scoped>
@import "@/app/styles/_variables";
@import "@/app/styles/_mixins";
.cocktail-list {
&__item {
display: block;
font-size: 1.8rem;
font-weight: bold;
line-height: 1.3;
margin-bottom: 15px;
text-decoration: none;
color: #000;
@include get-media($mobile, $tablet) {
display: inline-block;
font-size: 1.4rem;
margin-right: 15px;
}
&::first-letter {
text-transform: capitalize;
}
&:visited {
color: #000;
}
&:active,
&.router-link-exact-active {
color: green;
}
}
}
</style>
5 changes: 5 additions & 0 deletions src/modules/cocktails/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import router from './router'

export default {
router,
}
37 changes: 37 additions & 0 deletions src/modules/cocktails/pages/CocktailMain.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<div class="cocktail-main">
<div class="cocktail-main__list"><CocktailList /></div>
<div class="cocktail-main__view">
<router-view />
</div>
</div>
</template>

<script setup lang="ts">
import CocktailList from '../components/CocktailList.vue'
</script>

<style lang="scss" scoped>
@import "@/app/styles/_variables";
@import "@/app/styles/_mixins";
.cocktail-main {
display: flex;
justify-content: flex-start;
align-items: stretch;
@include get-media($mobile, $tablet) {
flex-direction: column;
}
&__list {
padding: 13px 15px;
min-width: 200px;
}
&__view {
flex-grow: 1;
padding: 15px;
}
}
</style>
Loading

0 comments on commit 36194b3

Please sign in to comment.