Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IT2810_P2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IT2810-H19
T
Teams
Team 36
IT2810_P2
Commits
e1e21169
Commit
e1e21169
authored
Sep 23, 2019
by
Svein Olav Styve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#15
Update Title Component
parent
87346282
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
src/App.js
src/App.js
+1
-7
src/App.test.js
src/App.test.js
+6
-1
src/__snapshots__/App.test.js.snap
src/__snapshots__/App.test.js.snap
+1
-1
src/components/Title.js
src/components/Title.js
+11
-1
No files found.
src/App.js
View file @
e1e21169
...
...
@@ -20,7 +20,6 @@ class App extends React.Component {
super
(
props
);
this
.
handleArtworkChange
=
this
.
handleArtworkChange
.
bind
(
this
);
this
.
getImageTitle
=
this
.
getImageTitle
.
bind
(
this
);
this
.
handleCategoryChange
=
this
.
handleCategoryChange
.
bind
(
this
);
this
.
checkForEmptyLocalStorage
=
this
.
checkForEmptyLocalStorage
.
bind
(
this
);
this
.
saveAsFavorite
=
this
.
saveAsFavorite
.
bind
(
this
);
...
...
@@ -121,11 +120,6 @@ class App extends React.Component {
this
.
setState
({
artwork
:
artworkId
},
event
=>
this
.
updateSession
());
}
getImageTitle
()
{
let
titles
=
[
"
Artwork 1
"
,
"
Artwork 2
"
,
"
Artwork 3
"
,
"
Artwork 4
"
];
return
titles
[
this
.
state
.
artwork
]
+
JSON
.
stringify
(
this
.
state
.
categorySelections
);
// CategorySelection added for testing
}
handleCategoryChange
(
name
,
valueAsString
)
{
let
value
=
parseInt
(
valueAsString
);
const
oldCatSel
=
this
.
state
.
categorySelections
;
...
...
@@ -180,7 +174,7 @@ class App extends React.Component {
<
div
className
=
"
App
"
>
<
header
className
=
"
App-header
"
>
<
div
className
=
"
title
"
>
<
Title
title
=
{
this
.
getImageTitle
()
}
/
>
<
Title
artwork
=
{
this
.
state
.
artwork
}
categorySelections
=
{
this
.
state
.
categorySelections
}
/
>
<
/div
>
<
div
className
=
"
cluster
"
>
<
div
className
=
"
chooser
"
>
...
...
src/App.test.js
View file @
e1e21169
...
...
@@ -13,7 +13,12 @@ describe('My Test Suite', () => {
// Snapshot Test Title-component
describe
(
'
Title
'
,
()
=>
{
test
(
'
snapshot renders
'
,
()
=>
{
const
component
=
renderer
.
create
(
<
Title
title
=
{
"
my title
"
}
/>
)
;
const
component
=
renderer
.
create
(
<
Title
artworkId
=
{
1
}
categorySelections
=
{{
textCat
:
1
,
imageCat
:
1
,
audioCat
:
1
,
}}
/>
)
;
let
tree
=
component
.
toJSON
();
expect
(
tree
).
toMatchSnapshot
();
});
...
...
src/__snapshots__/App.test.js.snap
View file @
e1e21169
...
...
@@ -4,6 +4,6 @@ exports[`Title snapshot renders 1`] = `
<h1
className="Title"
>
my title
undefined, txt 2, img 2, audio 2
</h1>
`;
src/components/Title.js
View file @
e1e21169
import
React
from
'
react
'
;
function
getImageTitle
(
artworkId
,
categorySelections
)
{
let
titles
=
[
"
Artwork 1
"
,
"
Artwork 2
"
,
"
Artwork 3
"
,
"
Artwork 4
"
];
let
txtCatTitles
=
[
"
txt 1
"
,
"
txt 2
"
,
"
txt 3
"
,
"
txt 4
"
];
let
imgCatTitles
=
[
"
img 1
"
,
"
img 2
"
,
"
img 3
"
,
"
img 4
"
];
let
audioCatTitles
=
[
"
audio 1
"
,
"
audio 2
"
,
"
audio 3
"
,
"
audio 4
"
];
return
titles
[
artworkId
]
+
"
,
"
+
txtCatTitles
[
categorySelections
.
textCat
]
+
"
,
"
+
imgCatTitles
[
categorySelections
.
imageCat
]
+
"
,
"
+
audioCatTitles
[
categorySelections
.
audioCat
]
}
function
Title
(
props
)
{
return
(
<
h1
className
=
"
Title
"
>
{
props
.
title
}
<
/h1
>
<
h1
className
=
"
Title
"
>
{
getImageTitle
(
props
.
artwork
,
props
.
categorySelections
)
}
<
/h1
>
)
}
...
...
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