Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
angular-component-paths-exercise
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shaphen Pangburn
angular-component-paths-exercise
Commits
4b799357
Commit
4b799357
authored
Apr 21, 2021
by
Shaphen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add and style contact Us form
parent
e5f38b8b
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
149 additions
and
23 deletions
+149
-23
account.component.ts
src/app/account/account.component.ts
+4
-4
app-routing.module.ts
src/app/app-routing.module.ts
+3
-1
app.module.ts
src/app/app.module.ts
+4
-2
contact-us.component.css
src/app/contact-us/contact-us.component.css
+40
-0
contact-us.component.html
src/app/contact-us/contact-us.component.html
+29
-0
contact-us.component.spec.ts
src/app/contact-us/contact-us.component.spec.ts
+28
-0
contact-us.component.ts
src/app/contact-us/contact-us.component.ts
+36
-0
footer.component.html
src/app/footer/footer.component.html
+3
-3
styles.css
src/styles.css
+2
-13
No files found.
src/app/account/account.component.ts
View file @
4b799357
...
@@ -21,9 +21,9 @@ export class AccountComponent implements OnInit {
...
@@ -21,9 +21,9 @@ export class AccountComponent implements OnInit {
ngOnInit
():
void
{
ngOnInit
():
void
{
this
.
userForm
=
this
.
formBuilder
.
group
({
this
.
userForm
=
this
.
formBuilder
.
group
({
firstName
:
[
''
,
[
Validators
.
required
,
Validators
.
pattern
(
'^[a-zA-Z]+$'
)
]],
firstName
:
[
''
,
[
Validators
.
required
]],
lastName
:
[
''
,[
Validators
.
required
,
Validators
.
pattern
(
'^[a-zA-Z]+$'
)]],
lastName
:
[
''
,[
Validators
.
required
,
Validators
.
pattern
(
'^[a-zA-Z]+$'
)]],
email
:
[
''
,
[
Validators
.
required
,
Validators
.
pattern
(
'[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}'
)]]
email
:
[
''
,
[
Validators
.
required
,
Validators
.
pattern
(
'[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}'
)]]
});
});
}
}
...
...
src/app/app-routing.module.ts
View file @
4b799357
...
@@ -5,13 +5,15 @@ import { FranceComponent } from './france/france.component';
...
@@ -5,13 +5,15 @@ import { FranceComponent } from './france/france.component';
import
{
GreeceComponent
}
from
'./greece/greece.component'
;
import
{
GreeceComponent
}
from
'./greece/greece.component'
;
import
{
SpainComponent
}
from
'./spain/spain.component'
;
import
{
SpainComponent
}
from
'./spain/spain.component'
;
import
{
AccountComponent
}
from
'./account/account.component'
;
import
{
AccountComponent
}
from
'./account/account.component'
;
import
{
ContactUsComponent
}
from
'./contact-us/contact-us.component'
;
const
routes
:
Routes
=
[
const
routes
:
Routes
=
[
{
path
:
'england'
,
component
:
EnglandComponent
},
{
path
:
'england'
,
component
:
EnglandComponent
},
{
path
:
'france'
,
component
:
FranceComponent
},
{
path
:
'france'
,
component
:
FranceComponent
},
{
path
:
'greece'
,
component
:
GreeceComponent
},
{
path
:
'greece'
,
component
:
GreeceComponent
},
{
path
:
'spain'
,
component
:
SpainComponent
},
{
path
:
'spain'
,
component
:
SpainComponent
},
{
path
:
'account'
,
component
:
AccountComponent
}
{
path
:
'account'
,
component
:
AccountComponent
},
{
path
:
'contact-us'
,
component
:
ContactUsComponent
}
];
];
@
NgModule
({
@
NgModule
({
...
...
src/app/app.module.ts
View file @
4b799357
...
@@ -13,6 +13,7 @@ import { SpainComponent } from './spain/spain.component';
...
@@ -13,6 +13,7 @@ import { SpainComponent } from './spain/spain.component';
import
{
NgbModule
}
from
'@ng-bootstrap/ng-bootstrap'
;
import
{
NgbModule
}
from
'@ng-bootstrap/ng-bootstrap'
;
import
{
IvyCarouselModule
}
from
'angular-responsive-carousel'
;
import
{
IvyCarouselModule
}
from
'angular-responsive-carousel'
;
import
{
AccountComponent
}
from
'./account/account.component'
;
import
{
AccountComponent
}
from
'./account/account.component'
;
import
{
ContactUsComponent
}
from
'./contact-us/contact-us.component'
;
@
NgModule
({
@
NgModule
({
...
@@ -24,7 +25,8 @@ import { AccountComponent } from './account/account.component';
...
@@ -24,7 +25,8 @@ import { AccountComponent } from './account/account.component';
FranceComponent
,
FranceComponent
,
GreeceComponent
,
GreeceComponent
,
SpainComponent
,
SpainComponent
,
AccountComponent
AccountComponent
,
ContactUsComponent
],
],
imports
:
[
imports
:
[
BrowserModule
,
BrowserModule
,
...
...
src/app/contact-us/contact-us.component.css
0 → 100644
View file @
4b799357
.contact-us-container
{
height
:
80vh
;
display
:
flex
;
justify-content
:
center
;
margin-top
:
50px
;
}
.message-form
{
display
:
inline-block
;
text-align
:
center
;
}
.message-form-input
{
width
:
600px
;
border
:
1px
solid
#cccccc
;
border-radius
:
5px
;
padding
:
5px
;
outline
:
none
;
margin-top
:
10px
;
}
.textarea
{
height
:
120px
;
}
.submit-button
{
border
:
1px
solid
#ccc
;
border-radius
:
5px
;
padding
:
10px
274px
;
margin-top
:
5px
;
}
.ng-invalid.ng-touched
:not
(
form
)
{
border
:
2px
solid
red
;
}
.contact-error-message
{
margin
:
0px
2px
0px
;
color
:
red
;
}
\ No newline at end of file
src/app/contact-us/contact-us.component.html
0 → 100644
View file @
4b799357
<div
class=
"contact-us-container"
>
<form
[
formGroup
]="
contactForm
"
(
ngSubmit
)="
onSubmit
()"
>
<h1>
Contact Us
</h1>
<div
class=
"message-input-container"
>
<div>
<input
type=
"text"
formControlName=
"firstName"
class=
"message-form-input input"
placeholder=
"First name"
>
</div>
<p
class=
"contact-error-message"
*
ngIf=
"contactForm.get('firstName').errors && contactForm.get('firstName').hasError('required') && contactForm.get('firstName').touched"
>
First Name is Required!
</p>
<div>
<input
type=
"text"
formControlName=
"lastName"
class=
"message-form-input input "
placeholder=
"Last name"
>
</div>
<p
class=
"contact-error-message"
*
ngIf=
"contactForm.get('lastName').errors && contactForm.get('lastName').hasError('required') && contactForm.get('lastName').touched"
>
Last Name is Required!
</p>
<div>
<input
type=
"email"
formControlName=
"email"
class=
"message-form-input input"
placeholder=
"Email"
>
</div>
<p
class=
"contact-error-message"
*
ngIf=
"contactForm.get('email').errors && contactForm.get('email').hasError('required') && contactForm.get('email').touched"
>
Email is Required!
</p>
</div>
<textarea
type=
"textarea"
wrap=
"hard"
class=
"message-form-input textarea"
placeholder=
"What can we help you with?"
></textarea>
<div>
<button
class=
"submit-button"
type=
"submit"
>
Submit
</button>
</div>
</form>
</div>
src/app/contact-us/contact-us.component.spec.ts
0 → 100644
View file @
4b799357
/* tslint:disable:no-unused-variable */
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
By
}
from
'@angular/platform-browser'
;
import
{
DebugElement
}
from
'@angular/core'
;
import
{
ContactUsComponent
}
from
'./contact-us.component'
;
describe
(
'ContactUsComponent'
,
()
=>
{
let
component
:
ContactUsComponent
;
let
fixture
:
ComponentFixture
<
ContactUsComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
ContactUsComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
ContactUsComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/contact-us/contact-us.component.ts
0 → 100644
View file @
4b799357
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
FormBuilder
,
Validators
}
from
'@angular/forms'
;
import
{
NgForm
}
from
'@angular/forms'
;
@
Component
({
selector
:
'app-contact-us'
,
templateUrl
:
'./contact-us.component.html'
,
styleUrls
:
[
'./contact-us.component.css'
]
})
export
class
ContactUsComponent
implements
OnInit
{
public
contactForm
;
public
showMessage
:
boolean
=
false
;
public
invalidEntry
=
"Invalid Entry"
;
constructor
(
private
formBuilder
:
FormBuilder
)
{
}
ngOnInit
()
{
this
.
contactForm
=
this
.
formBuilder
.
group
({
firstName
:
[
''
,
[
Validators
.
required
]],
lastName
:
[
''
,[
Validators
.
required
]],
email
:
[
''
,
[
Validators
.
required
]],
});
}
onSubmit
(){
if
(
this
.
contactForm
.
valid
)
{
alert
(
"You message was successfully sent!"
)
}
else
{
alert
(
"Big no, pls fix"
)
}
}
get
firstName
()
{
return
this
.
contactForm
.
firstName
}
get
lastName
()
{
return
this
.
lastName
}
get
email
()
{
return
this
.
email
}
}
src/app/footer/footer.component.html
View file @
4b799357
<div
class=
'footer'
>
<div
class=
'footer'
>
<ul>
<ul>
<li>
About Us
</li>
<li
id=
"no-reaction"
>
About Us
</li>
<li>
Careers
</li>
<li
id=
"no-reaction"
>
Careers
</li>
<li>
Contact Us
</li>
<li
[
routerLink
]="['/
contact-us
']"
>
Contact Us
</li>
</ul>
</ul>
</div>
</div>
\ No newline at end of file
src/styles.css
View file @
4b799357
...
@@ -26,17 +26,6 @@
...
@@ -26,17 +26,6 @@
width
:
100%
;
width
:
100%
;
}
}
::ng-deep
.carousel-item
{
#no-reaction
{
display
:
block
!important
;
cursor
:
default
;
position
:
absolute
;
transform
:
translateY
(
100%
);
opacity
:
0
;
transition
:
all
1s
;
}
::ng-deep
.carousel-item.active
{
position
:
relative
;
transform
:
translateY
(
0
);
opacity
:
1
;
top
:
0
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment