-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #636 from danskernesdigitalebibliotek/DDFFORM-611-…
…backend-anbefalings-komp DDFFORM 611 backend anbefalings komp
- Loading branch information
Showing
14 changed files
with
674 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@import "./src/styles/scss/tools"; | ||
|
||
// CSS sheets that are used to style the admin interface. | ||
@import "./src/stories/Library/opening-hours-editor/opening-hours-editor"; | ||
@import "./src/stories/Library/material-search/material-search"; | ||
@import "./src/stories/Library/cover/cover"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/stories/Library/material-search/MaterialSearch.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
|
||
import MaterialSearch from "./MaterialSearch"; | ||
|
||
export default { | ||
title: "Library / Material Search", | ||
component: MaterialSearch, | ||
argTypes: {}, | ||
} as ComponentMeta<typeof MaterialSearch>; | ||
|
||
const uniqueIdentifier = Math.floor(Math.random() * 10000); | ||
|
||
const Template: ComponentStory<typeof MaterialSearch> = () => { | ||
return ( | ||
<div className="material-search"> | ||
<div className="material-search__inputs-container"> | ||
<label | ||
className="material-search__label" | ||
htmlFor="hidden-work-id-input" | ||
> | ||
Hidden Work ID field | ||
<input | ||
data-field-input-work-id={uniqueIdentifier} | ||
id="hidden-work-id-input" | ||
type="text" | ||
placeholder="" | ||
className="material-search__input" | ||
disabled | ||
/> | ||
</label> | ||
<label | ||
className="material-search__label" | ||
htmlFor="hidden-material-type-input" | ||
> | ||
Hidden Material Type field | ||
<input | ||
type="text" | ||
id="hidden-material-type-input" | ||
data-field-input-material-type-id={uniqueIdentifier} | ||
className="material-search__input" | ||
disabled | ||
/> | ||
</label> | ||
</div> | ||
|
||
<MaterialSearch /> | ||
</div> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { FC, useState } from "react"; | ||
import MaterialSearchInputs from "./MaterialSearchInputs"; | ||
import MaterialSearchPreview from "./MaterialSearchPreview"; | ||
import MaterialSearchList from "./MaterialSearchList"; | ||
import { PreviewData } from "./MaterialSearchExampleData"; | ||
|
||
const MaterialSearch: FC = () => { | ||
const [searchInput, setSearchInput] = useState(""); | ||
const [selectedMaterialType, setSelectedMaterialType] = useState(""); | ||
const [selectedWorkId] = useState(PreviewData.workId); | ||
|
||
const handleSetSearchInput = (value: string) => { | ||
setSearchInput(value); | ||
}; | ||
|
||
return ( | ||
<div className="material-search"> | ||
<MaterialSearchInputs | ||
searchInput={searchInput} | ||
setSearchInput={handleSetSearchInput} | ||
selectedMaterialType={selectedMaterialType} | ||
onMaterialTypeChange={setSelectedMaterialType} | ||
/> | ||
<div className="material-search__materials-wrapper"> | ||
<MaterialSearchPreview displayMaterial={searchInput.length > 1} /> | ||
<MaterialSearchList | ||
showListResults={searchInput.length > 1} | ||
selectedWorkId={selectedWorkId} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MaterialSearch; |
69 changes: 69 additions & 0 deletions
69
src/stories/Library/material-search/MaterialSearchExampleData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
export const MaterialTypes = [ | ||
"bog", | ||
"artikel", | ||
"tidsskrift", | ||
"lydbog", | ||
"film", | ||
"musik", | ||
"spil", | ||
]; | ||
|
||
export interface PreviewDataProps { | ||
coverUrl: string; | ||
title: string; | ||
author: string; | ||
publicationYear: number; | ||
source: string; | ||
workId: string; | ||
} | ||
export const PreviewData: PreviewDataProps = { | ||
coverUrl: "images/book_cover_6.jpg", | ||
title: "Rødhals", | ||
author: "Jo Nesbø", | ||
publicationYear: 2022, | ||
source: "eReolen", | ||
workId: "work-of:800010-katalog:99122475830405763", | ||
}; | ||
|
||
export const ListResultData: PreviewDataProps[] = [ | ||
{ | ||
coverUrl: "images/book_cover_3.jpg", | ||
title: "Book Title 3", | ||
author: "Author 3", | ||
publicationYear: 2019, | ||
source: "Library", | ||
workId: "work-of:800010-katalog:98432897", | ||
}, | ||
{ | ||
coverUrl: "images/book_cover_2.jpg", | ||
title: "Book Title 2", | ||
author: "Author 2", | ||
publicationYear: 2020, | ||
source: "eReolen", | ||
workId: "work-of:800010-katalog:2389129", | ||
}, | ||
{ | ||
coverUrl: "images/book_cover_6.jpg", | ||
title: "Rødhals", | ||
author: "Jo Nesbø", | ||
publicationYear: 2022, | ||
source: "eReolen", | ||
workId: "work-of:800010-katalog:99122475830405763", | ||
}, | ||
{ | ||
coverUrl: "images/book_cover_4.jpg", | ||
title: "Book Title 4", | ||
author: "Author 4", | ||
publicationYear: 2018, | ||
source: "eReolen", | ||
workId: "work-of:800010-katalog:9778817", | ||
}, | ||
{ | ||
coverUrl: "images/book_cover_5.jpg", | ||
title: "Book Title 5", | ||
author: "Author 5", | ||
publicationYear: 2017, | ||
source: "Library", | ||
workId: "work-of:800010-katalog:2093", | ||
}, | ||
]; |
55 changes: 55 additions & 0 deletions
55
src/stories/Library/material-search/MaterialSearchInputs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { MaterialTypes } from "./MaterialSearchExampleData"; | ||
|
||
interface MaterialSearchInputsProps { | ||
searchInput: string; | ||
selectedMaterialType: string; | ||
setSearchInput: (value: string) => void; | ||
onMaterialTypeChange: (value: string) => void; | ||
} | ||
|
||
const MaterialSearchInputs = ({ | ||
searchInput, | ||
selectedMaterialType, | ||
setSearchInput, | ||
onMaterialTypeChange, | ||
}: MaterialSearchInputsProps) => { | ||
return ( | ||
<div className="material-search__inputs-container"> | ||
<label className="material-search__label" htmlFor="material-search-input"> | ||
Search for materials | ||
<input | ||
id="material-search-input" | ||
type="search" | ||
value={searchInput} | ||
onChange={(e) => setSearchInput(e.target.value)} | ||
placeholder="Enter search terms" | ||
className="material-search__input" | ||
/> | ||
</label> | ||
<label | ||
className="material-search__label" | ||
htmlFor="material-type-selector" | ||
> | ||
Choose material type | ||
<select | ||
id="material-type-selector" | ||
className="material-search__selector" | ||
disabled={!searchInput} | ||
onChange={(e) => onMaterialTypeChange(e.target.value)} | ||
value={selectedMaterialType || ""} | ||
> | ||
<option value="" disabled> | ||
-- Choose material type -- | ||
</option> | ||
{MaterialTypes.map((materialType: string) => ( | ||
<option key={materialType} value={materialType}> | ||
{materialType} | ||
</option> | ||
))} | ||
</select> | ||
</label> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MaterialSearchInputs; |
Oops, something went wrong.