add header and lang switcher
This commit is contained in:
+124
-17
@@ -22,6 +22,14 @@
|
|||||||
|
|
||||||
|
|
||||||
///////////////////// mixins
|
///////////////////// mixins
|
||||||
|
@mixin defaultTransition() {
|
||||||
|
transition: 0.3s;
|
||||||
|
-webkit-transition: 0.3s;
|
||||||
|
-moz-transition: 0.3s;
|
||||||
|
-ms-transition: 0.3s;
|
||||||
|
-o-transition: 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
@mixin transition($p) {
|
@mixin transition($p) {
|
||||||
transition: $p;
|
transition: $p;
|
||||||
-webkit-transition: $p;
|
-webkit-transition: $p;
|
||||||
@@ -68,6 +76,7 @@ $darkGray: #303030;
|
|||||||
|
|
||||||
body {
|
body {
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
|
background: $bg;
|
||||||
|
|
||||||
&:lang(en) {
|
&:lang(en) {
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
@@ -83,6 +92,15 @@ h1, h2, h3, h4, h5, h6 {
|
|||||||
font-family: 'sahel-bold';
|
font-family: 'sahel-bold';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: rgba(0, 0, 0, 0.7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/////// global classes
|
/////// global classes
|
||||||
.logo {
|
.logo {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@@ -93,33 +111,122 @@ h1, h2, h3, h4, h5, h6 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.lang--bar {
|
.header {
|
||||||
|
width: 100%;
|
||||||
|
background: #fff;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
.links {
|
||||||
|
li {
|
||||||
|
text-align: right;
|
||||||
|
padding: 30px 0;
|
||||||
|
|
||||||
|
&:lang(en) {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
text-align: right;
|
||||||
|
|
||||||
|
&:lang(en) {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
a:not(.logo) {
|
||||||
|
position: relative;
|
||||||
|
padding: 5px 0;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
width: 20px;
|
||||||
|
height: 1px;
|
||||||
background: $darkGray;
|
background: $darkGray;
|
||||||
height: 25px;
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
@include defaultTransition;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:lang(en) {
|
||||||
|
&::after {
|
||||||
|
right: auto;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
&::after {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.lag-switcher {
|
||||||
|
.dropdown {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
@include defaultTransition();
|
||||||
|
padding: 5px;
|
||||||
|
|
||||||
p {
|
p {
|
||||||
color: rgba(255, 255, 255, 0.7);
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 25px;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
|
||||||
@extend %appearance;
|
|
||||||
@extend %userSelect;
|
@extend %userSelect;
|
||||||
|
@include defaultTransition();
|
||||||
|
text-align: center;
|
||||||
|
font-size: 23px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropMenu {
|
||||||
|
width: 100%;
|
||||||
|
height: 0;
|
||||||
|
overflow: hidden;
|
||||||
background: $darkGray;
|
background: $darkGray;
|
||||||
color: #fff;
|
@include defaultTransition();
|
||||||
font-family: sans-serif;
|
position: absolute;
|
||||||
border: none;
|
top: 27px;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
option{
|
.drop-item {
|
||||||
|
padding-top: 10px;
|
||||||
|
|
||||||
|
p {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
background: #fff;
|
color: #fff;
|
||||||
color: #000;
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
@extend %userSelect;
|
||||||
|
@include defaultTransition();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.dropdown-active {
|
||||||
|
.title {
|
||||||
|
background: $darkGray;
|
||||||
|
|
||||||
|
p {
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropMenu {
|
||||||
|
height: 75px;
|
||||||
|
|
||||||
|
p:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<header class="header">
|
<header class="header">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<nav class="row">
|
<nav class="row align-items-center">
|
||||||
<div class="col-12">
|
<div class="col-7 links">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<ul class="row">
|
<ul class="row align-items-center">
|
||||||
<nuxt-link :to="staticData.home.url" tag="li" exact class="col">
|
<nuxt-link :to="staticData.home.url" tag="li" exact class="col">
|
||||||
<a class="logo">
|
<a class="logo">
|
||||||
<logo/>
|
<logo/>
|
||||||
@@ -25,11 +25,26 @@
|
|||||||
<nuxt-link :to="staticData.contact.url" tag="li" exact class="col">
|
<nuxt-link :to="staticData.contact.url" tag="li" exact class="col">
|
||||||
<a>{{staticData.contact.title}}</a>
|
<a>{{staticData.contact.title}}</a>
|
||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-5 lag-switcher">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<ul class="row flex-row-reverse align-items-center">
|
||||||
<li>
|
<li>
|
||||||
<select name="" id="">
|
<div class="dropdown" id="lang">
|
||||||
<option value="fa" selected>فا</option>
|
<div class="title">
|
||||||
<option value="en" selected>EN</option>
|
<p class="current-lang">فا</p>
|
||||||
</select>
|
</div>
|
||||||
|
<div class="dropMenu">
|
||||||
|
<div class="drop-item">
|
||||||
|
<p id="fa" class="locales">فا</p>
|
||||||
|
</div>
|
||||||
|
<div class="drop-item">
|
||||||
|
<p id="en" class="locales">EN</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,6 +64,37 @@
|
|||||||
return this.$store.state.staticData.header.en
|
return this.$store.state.staticData.header.en
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
const that = this
|
||||||
|
/////////////// lang switcher dropdown
|
||||||
|
$('#lang').hover(function () {
|
||||||
|
$(this).toggleClass('dropdown-active')
|
||||||
|
})
|
||||||
|
|
||||||
|
/////////////// switching language
|
||||||
|
$('.locales').click(function () {
|
||||||
|
if ($(this).attr('id') === 'fa') {
|
||||||
|
const currentURL = window.location.href
|
||||||
|
const urlSplit = currentURL.split('en')
|
||||||
|
console.log(urlSplit)
|
||||||
|
if (urlSplit.length > 1) {
|
||||||
|
that.$router.push('/fa' + urlSplit[1])
|
||||||
|
$('html').attr({lang: 'fa'})
|
||||||
|
$('.current-lang').text('فا')
|
||||||
|
}
|
||||||
|
} else if ($(this).attr('id') === 'en') {
|
||||||
|
const currentURL = window.location.href
|
||||||
|
const urlSplit = currentURL.split('fa')
|
||||||
|
console.log(urlSplit)
|
||||||
|
if (urlSplit.length > 1) {
|
||||||
|
that.$router.push('/en' + urlSplit[1])
|
||||||
|
$('html').attr({lang: 'en'})
|
||||||
|
$('.current-lang').text('EN')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="lang--bar">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-6">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<p>تمامی اطلاعات این سایت برای شرکت اراک ریل محفوظ است</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<langBar/>
|
|
||||||
<site-header/>
|
<site-header/>
|
||||||
<nuxt/>
|
<nuxt/>
|
||||||
</div>
|
</div>
|
||||||
@@ -8,12 +7,18 @@
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
beforeCreate() {
|
beforeCreate() {
|
||||||
if (this.$route.params.lang === 'fa') {
|
if (this.$route.params.lang === 'fa') {
|
||||||
$('html').attr({lang: 'fa'})
|
$('html').attr({lang: 'fa'})
|
||||||
} else if (this.$route.params.lang === 'en') {
|
} else if (this.$route.params.lang === 'en') {
|
||||||
$('html').attr({lang: 'en'})
|
$('html').attr({lang: 'en'})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
head(){
|
||||||
|
return {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
export default function (ctx) {
|
||||||
|
if (ctx.app.store.state.global.navigation_guard) {
|
||||||
|
ctx.app.store.commit('global/navigationGuards', false)
|
||||||
|
|
||||||
|
/////////////////////////////////// beforeEach
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////// afterEach
|
||||||
|
ctx.app.router.afterEach((to, from) => {
|
||||||
|
if (to.params.lang === 'fa') {
|
||||||
|
$('html').attr({lang: 'fa'})
|
||||||
|
} else if (to.params.lang === 'en') {
|
||||||
|
$('html').attr({lang: 'en'})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+4
-1
@@ -79,5 +79,8 @@ export default {
|
|||||||
generate: {
|
generate: {
|
||||||
dir: '../../public/nuxt_build'
|
dir: '../../public/nuxt_build'
|
||||||
},
|
},
|
||||||
router: {}
|
router: {
|
||||||
|
mode: 'history',
|
||||||
|
middleware: 'routerGuards'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="home--page">
|
||||||
salam
|
<section class="s1">
|
||||||
|
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
-2
@@ -1,9 +1,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import header from '../components/header'
|
import header from '../components/header'
|
||||||
import logo from '../components/icons/logo'
|
import logo from '../components/icons/logo'
|
||||||
import langBar from '../components/langBar'
|
|
||||||
|
|
||||||
|
|
||||||
Vue.component('site-header', header)
|
Vue.component('site-header', header)
|
||||||
Vue.component('logo', logo)
|
Vue.component('logo', logo)
|
||||||
Vue.component('langBar', langBar)
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
export const state = () => ({
|
export const state = () => ({
|
||||||
navigation_guard: false
|
navigation_guard: true
|
||||||
})
|
})
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
|
|||||||
Reference in New Issue
Block a user