Skip to content

Commit

Permalink
add: some styling and tune for definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
4Furki4 committed May 29, 2023
1 parent 70a3e51 commit a3fecb6
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 48 deletions.
4 changes: 3 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
"src/assets"
],
"styles": [
"src/styles.scss"
"src/styles.scss",
"node_modules/ngx-spinner/animations/ball-8bits.css",
"node_modules/ngx-spinner/animations/ball-scale-multiple.css"
],
"scripts": []
},
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@angular/platform-browser": "^16.0.0",
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"ngx-spinner": "^16.0.2",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { MainModule } from './components/main/main.module';
import { HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
MainModule,
HttpClientModule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="daily-word-and-phrase">
<div class="daily-word-and-phrase container">
<div class="card">
<h2 class="card__title">Bir Kelime</h2>
<div class="card--inner" *ngFor="let word of words">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.daily-word-and-phrase {
width: 90%;
margin-inline: auto;
// width: 90%;
// margin-inline: auto;
display: grid;
grid-template-columns: 1fr;
gap: 2rem;
Expand Down
76 changes: 45 additions & 31 deletions src/app/components/main/definition/definition.component.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
<!-- <ngx-spinner type="ball-8bits" color="371B58" name="mySpinner"></ngx-spinner> -->
<ngx-spinner type="ball-scale-multiple" name="scale">
</ngx-spinner>
<ng-container *ngIf="word$ | async as word">
<div class="container definition" *ngFor="let word of (word$|async); let wordIndex = index">
<h1>
{{word.madde}}
</h1>
<p>
<i *ngIf="word.cogul_mu === '1'">
Çokluk,
</i>
<span *ngIf="word.telaffuz">
({{word.telaffuz}}),
</span>
<span>
{{word.lisan}}
</span>
</p>
<ng-container *ngFor="let anlam of anlamList[wordIndex]; let i = index">
<p>
{{anlam}}
<i *ngIf="word.ozel_mi === '1'">
özel
</i>
</p>
<p>{{ word.anlamlarListe[i].anlam }}</p>
<ng-container *ngIf="word.anlamlarListe[i].orneklerListe">
<q>
{{word.anlamlarListe[i].orneklerListe[0].ornek}}
</q>
<span *ngFor="let yazar of word.anlamlarListe[i].orneklerListe[0].yazar">
- {{yazar.tam_adi}}
</span>
<div [@sliding]="word ? 'void' : 'sliding-in'" class="container definition">
<div *ngFor="let word of (word$|async); let wordIndex = index">
<div>
<h1 class="definition__title">
{{word.madde }}
</h1>
<p>
<i *ngIf="word.cogul_mu === '1'">
Çokluk,
</i>
<i *ngIf="word.telaffuz">
({{word.telaffuz}}),
</i>
<i>
{{word.lisan}}
</i>
</p>
</div>
<ng-container *ngFor="let anlam of anlamList[wordIndex]; let i = index">
<div class="definition__meaning">
<ng-container *ngIf="word.anlamlarListe[i]">
<span>
{{i+1}}.
<i>{{anlam}}</i>
<i *ngIf="word.ozel_mi === '1'">
<span>, özel</span>
</i>
{{ word.anlamlarListe[i].anlam }}
</span>
<ng-container *ngIf="word.anlamlarListe[i].orneklerListe">
<div class="definition__example">
<q>
{{word.anlamlarListe[i].orneklerListe[0].ornek}}
</q>
<span *ngFor="let yazar of word.anlamlarListe[i].orneklerListe[0].yazar">
- {{yazar.tam_adi}}
</span>
</div>
</ng-container>
</ng-container>
</div>
</ng-container>
</ng-container>
</div>
</div>
</ng-container>
32 changes: 32 additions & 0 deletions src/app/components/main/definition/definition.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.definition {
background-color: var(--secondary-bg-color);
padding: clamp(0rem, 2vw, 2rem);
box-shadow: 0px 0px 10px var(--secondary-bg-color);
font-size: clamp(1rem, 5vw, 2rem);
transition: background-color .5s;

&__title {
padding: 0;
margin: 0;
text-align: center;
}

&__meaning {
>* {
margin: 1rem 0 1rem 0;
}

padding: 1rem;

// &:not(:last-child) {
// border-bottom: 1px solid var(--main-bg-color);
// }

border-bottom: 2px solid var(--main-bg-color);
}

&__example {
font-size: clamp(1rem, 5vw, 1.5rem);
text-align: center;
}
}
35 changes: 33 additions & 2 deletions src/app/components/main/definition/definition.component.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,57 @@
import { animate, state, style, transition, trigger } from '@angular/animations';
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { NgxSpinnerService } from 'ngx-spinner';
import { Observable, map, switchMap } from 'rxjs';
import { WordResponse } from 'src/app/models/word-response';
import { WordRequestService } from 'src/app/services/word-request.service';


//sliding animation
@Component({
selector: 'sozluk-definition',
templateUrl: './definition.component.html',
styleUrls: ['./definition.component.scss']
styleUrls: ['./definition.component.scss'],
animations: [
trigger('sliding', [
state('sliding', style({
transform: 'translateX(-100%)'
})),
state('sliding-out', style({
transform: 'translateX(100%)'
}
)),
state('sliding-in', style({
transform: 'translateX(0%)'
}
)),
transition('void => sliding', animate(0)),
transition('sliding => sliding-out', animate(250)),
])
]
})
export class DefinitionComponent implements OnInit {
ngOnInit(): void {

}
private wordService: WordRequestService = inject(WordRequestService);
private activatedRoute: ActivatedRoute = inject(ActivatedRoute);
private spinner: NgxSpinnerService = inject(NgxSpinnerService);
anlamList: Array<string[]> = [];
searchedWord !: string;
word$: Observable<WordResponse[]> = this.activatedRoute.paramMap.pipe(
map((param) => param.get('word')!),
switchMap((word) => this.wordService.requestWordMeaning(word)),
switchMap((word) => {
if (word === this.searchedWord) { }
return this.wordService.requestWordMeaning(word)
}),
map((httpResponse) => {
this.spinner.show('scale', {
type: 'ball-scale-multiple'
})
this.anlamList = new Array<string[]>()
httpResponse.forEach((wordResponse, index) => {
this.searchedWord = wordResponse.madde
let anlamCount = parseInt(wordResponse.anlam_say, 10)
let anlamOzellik !: string;
let anlamOzellikListe = new Array<string>()
Expand All @@ -32,6 +62,7 @@ export class DefinitionComponent implements OnInit {
}
this.anlamList.push(anlamOzellikListe)
})
this.spinner.hide('scale', 250)
return httpResponse;
})
);
Expand Down
7 changes: 3 additions & 4 deletions src/app/components/main/definition/definition.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DefinitionComponent } from './definition.component';
import { RouterModule } from '@angular/router';



import { NgxSpinnerModule } from 'ngx-spinner';
@NgModule({
declarations: [
DefinitionComponent
Expand All @@ -13,7 +11,8 @@ import { RouterModule } from '@angular/router';
CommonModule,
RouterModule.forChild([
{ path: '', component: DefinitionComponent }
])
]),
NgxSpinnerModule
]
})
export class DefinitionModule { }
4 changes: 0 additions & 4 deletions src/app/components/main/main.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import { SearchInputComponent } from './search-input/search-input.component';
import { RouterModule } from '@angular/router';
import { DailyWordAndPhraseComponent } from './daily-word-and-phrase/daily-word-and-phrase.component';
import { FormsModule } from '@angular/forms';




@NgModule({
declarations: [
MainComponent,
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/main/navbar/navbar.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<nav class="nav container">
<nav class="nav">
<div class="nav--wrapper">
<div class="nav__logo">
<img src="../../../assets/svg/logo.svg" alt="" />
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/main/navbar/navbar.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
box-shadow: 0px 2px 3px var(--secondary-bg-color);
position: sticky;
top: 0;
z-index: 99;

&--wrapper {
width: min(98%, 900px);
width: min(98%, 1200px);
margin-inline: auto;
display: flex;
flex-direction: row;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{wordInput}}
<section class="search container">
<form (ngSubmit)="onSubmit()" #searchForm="ngForm" class="search__form">
<label class="search__label" for="word">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.search {
z-index: 0;
margin-top: 4rem;

&__label {
Expand Down
6 changes: 6 additions & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ body {
color: var(--main-color);
color-scheme: var(--color-scheme);
transition: background-color 0.5s ease-out, color 0.5s ease-out;
}

.container {
width: min(1200px, 80%);
margin-inline: auto;
margin-top: 2rem;
}

0 comments on commit a3fecb6

Please sign in to comment.