Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dop 3789 #853

Merged
merged 35 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1b62003
DOP-3785: adding a persistent search bar
bianca-laube Jun 21, 2023
ffaa041
updating tests for new front end change
bianca-laube Jun 23, 2023
2eb0303
updating snapshots
bianca-laube Jun 23, 2023
af0b115
DOP-3788: changed the chips css and showed result numbers
bianca-laube Jun 26, 2023
108b194
updated snapshots
bianca-laube Jun 27, 2023
d2889fb
fixed component
bianca-laube Jun 27, 2023
736d213
fixing miniscule details
bianca-laube Jun 27, 2023
16509a8
fixed empty search and placeholder value
bianca-laube Jun 28, 2023
eed1e24
Adding feature flag
bianca-laube Jun 29, 2023
8356841
fixing empty container on empty search
bianca-laube Jul 5, 2023
2819361
updated tests snapshots
bianca-laube Jul 5, 2023
660587f
updating border radius
bianca-laube Jul 5, 2023
e47ab53
DOP-3789: updating card styling
bianca-laube Jul 6, 2023
620dbab
proper format for empty result on prod
bianca-laube Jul 6, 2023
2a0669d
catching infinite load edge case
bianca-laube Jul 7, 2023
14d0c7c
changing link colour if selected in history
bianca-laube Jul 7, 2023
9fcda2f
fixing infinite loop edge case second location
bianca-laube Jul 7, 2023
f667fb6
getting rid of redunt checks
bianca-laube Jul 7, 2023
ac10901
Merge branch 'master' into DOP-3785
bianca-laube Jul 7, 2023
7069943
merging with the updated DOP-3785 ticket
bianca-laube Jul 7, 2023
060932e
added the feature flag
bianca-laube Jul 7, 2023
f072d3a
fixing cards in mobile view
bianca-laube Jul 7, 2023
9a1c234
Merge branch 'DOP-3788' into DOP-3789
bianca-laube Jul 7, 2023
63da229
fixing the colour of the title
bianca-laube Jul 7, 2023
33e813b
adding feature flag
bianca-laube Jul 10, 2023
ab571c9
fixing html sanitizer
bianca-laube Jul 10, 2023
f4bdc8d
changed styleTag with feature flag
bianca-laube Jul 10, 2023
6c0ab2f
FIXED sanitizeHTML
bianca-laube Jul 10, 2023
b06bf47
updated changed with DOP-3788
bianca-laube Jul 10, 2023
a1dcea3
updated with master
bianca-laube Jul 11, 2023
36a1f24
working completely with the feature flag
bianca-laube Jul 12, 2023
5ea7d0c
Refactoring code
bianca-laube Jul 13, 2023
e233b4b
refactoring ternary statments
bianca-laube Jul 14, 2023
a9c553d
merging with master
bianca-laube Jul 17, 2023
7466676
changed naming of variable
bianca-laube Jul 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions src/components/SearchResults/SearchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ import SearchContext from './SearchContext';

const LINK_COLOR = '#494747';
// Use string for match styles due to replace/innerHTML
const SEARCH_MATCH_STYLE = `background-color: ${palette.yellow.light2};`;
const newSearchInput = process.env.GATSBY_TEST_SEARCH_UI === 'true';
const SEARCH_MATCH_STYLE = newSearchInput
? `background-color: ${palette.green.light2} ; border-radius: 3px; padding-left: 2px; padding-right: 2px;`
: `background-color: ${palette.yellow.light2};`;

const largeResultTitle = css`
font-size: ${theme.size.default};
line-height: ${theme.size.medium};
/* Only add bold on larger devices */
@media ${theme.screenSize.smallAndUp} {
font-weight: 600;
}
font-weight: 600;
`;

// Truncates text to a maximum number of lines
Expand All @@ -45,10 +44,21 @@ const LearnMoreLink = styled('a')`

const SearchResultContainer = styled('div')`
height: 100%;
`;

const StyledResultTitle = styled('p')`
font-family: 'Euclid Circular A';
${newSearchInput ? `color: #016bf8;` : ``}
font-size: ${theme.fontSize.small};
line-height: ${theme.size.medium};
letter-spacing: 0.5px;
height: ${theme.size.medium};
margin-bottom: ${theme.size.small};
margin-top: 0;
${truncate(1)};
${({ useLargeTitle }) => useLargeTitle && largeResultTitle};
@media ${theme.screenSize.upToSmall} {
display: flex;
flex-direction: column;
height: 100%;
${largeResultTitle};
}
position: relative;
`;
Expand All @@ -67,6 +77,9 @@ const SearchResultLink = styled('a')`
transition: background-color 150ms ease-in;
}
}
:visited {
${newSearchInput ? `${StyledResultTitle} {color: #5e0c9e;}` : ``}
}
`;

const StyledPreviewText = styled(Body)`
Expand All @@ -78,21 +91,6 @@ const StyledPreviewText = styled(Body)`
min-height: 20px;
`;

const StyledResultTitle = styled('p')`
font-family: 'Euclid Circular A';
font-size: ${theme.fontSize.small};
line-height: ${theme.size.medium};
letter-spacing: 0.5px;
height: ${theme.size.medium};
margin-bottom: ${theme.size.small};
margin-top: 0;
${truncate(1)};
${({ useLargeTitle }) => useLargeTitle && largeResultTitle};
@media ${theme.screenSize.upToSmall} {
${largeResultTitle};
}
`;

const StyledTag = styled(Tag)`
${newSearchInput ? searchTagStyleFeature : searchTagStyle}
`;
Expand All @@ -110,12 +108,23 @@ const highlightSearchTerm = (text, searchTerm) =>
(result) => `<span style="${SEARCH_MATCH_STYLE}">${result}</span>`
);

const spanAllowedStyles = newSearchInput
? {
'background-color': [new RegExp(`^${palette.green.light2}$`, 'i')],
'border-radius': [new RegExp(`^3px$`)],
'padding-left': [new RegExp(`^2px$`)],
'padding-right': [new RegExp(`^2px$`)],
}
: { 'background-color': [new RegExp(`^${palette.yellow.light2}$`, 'i')] };

// since we are using dangerouslySetInnerHTML, this helper sanitizes input to be safe
const sanitizePreviewHtml = (text) =>
sanitizeHtml(text, {
allowedTags: ['span'],
allowedAttributes: { span: ['style'] },
allowedStyles: { span: { 'background-color': [new RegExp(`^${palette.yellow.light2}$`, 'i')] } },
allowedStyles: {
span: spanAllowedStyles,
},
});

const SearchResult = React.memo(
Expand All @@ -142,7 +151,7 @@ const SearchResult = React.memo(
<SearchResultContainer>
<StyledResultTitle
dangerouslySetInnerHTML={{
__html: sanitizePreviewHtml(highlightedTitle),
__html: sanitizePreviewHtml(newSearchInput ? title : highlightedTitle),
}}
useLargeTitle={useLargeTitle}
/>
Expand Down
16 changes: 11 additions & 5 deletions src/components/SearchResults/SearchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,20 @@ const StyledSearchFilters = styled(SearchFilters)`
`;

const searchResultStyling = css`
${newSearchInput
? `
box-shadow: 0px 0px 3px 0px rgba(0, 0, 0, 0.1);
border-radius: 45px;
`
: `box-shadow: 0 0 ${theme.size.tiny} 0 rgba(231, 238, 236, 0.4);`}
background-color: #fff;
box-shadow: 0 0 ${theme.size.tiny} 0 rgba(231, 238, 236, 0.4);
height: ${SEARCH_RESULT_HEIGHT};
position: relative;
/* place-self adds both align-self and justify-self for flexbox */
place-self: center;
width: 100%;
> div {
padding: ${theme.size.medium};
${newSearchInput ? `padding: 20px; padding-left: 30px;` : `padding: ${theme.size.medium};`}
}
:hover,
:focus {
Expand Down Expand Up @@ -198,10 +203,11 @@ const StyledSearchResults = styled('div')`
/* Create the opaque effect on hover by opaquing everything but a hovered result */
:hover {
> ${StyledSearchResult} {
opacity: 0.2;
transition: opacity 150ms ease-in;
${!newSearchInput && `opacity: 0.2; transition: opacity 150ms ease-in;`}

:hover {
opacity: 1;
${newSearchInput && `box-shadow: 0px 0px 5px 1px rgba(58, 63, 60, 0.15);`}
}
}
}
Expand Down Expand Up @@ -311,7 +317,7 @@ const SearchResults = () => {
<Global
styles={css`
body {
background-color: #f9fbfa !important;
${newSearchInput ? `background-color: #ffffff !important;` : ` background-color: #f9fbfa !important;`}
}
`}
/>
Expand Down
66 changes: 10 additions & 56 deletions tests/unit/__snapshots__/SearchResults.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ exports[`Search Results Page considers a given search filter query param and dis
-webkit-text-decoration: none;
text-decoration: none;
border-radius: 24px;
background-color: #fff;
box-shadow: 0 0 4px 0 rgba(231, 238, 236, 0.4);
background-color: #fff;
height: 152px;
position: relative;
place-self: center;
Expand Down Expand Up @@ -280,20 +280,6 @@ exports[`Search Results Page considers a given search filter query param and dis

.emotion-23 {
height: 100%;
position: relative;
}

@media only screen and (max-width: 480px) {
.emotion-23 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
height: 100%;
}
bianca-laube marked this conversation as resolved.
Show resolved Hide resolved
}

.emotion-25 {
Expand All @@ -310,24 +296,15 @@ exports[`Search Results Page considers a given search filter query param and dis
overflow: hidden;
font-size: 16px;
line-height: 24px;
}

@media not all and (max-width: 480px) {
.emotion-25 {
font-weight: 600;
}
font-weight: 600;
position: relative;
}

@media only screen and (max-width: 480px) {
.emotion-25 {
font-size: 16px;
line-height: 24px;
}

@media not all and (max-width: 480px) {
.emotion-25 {
font-weight: 600;
}
font-weight: 600;
bianca-laube marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -2374,8 +2351,8 @@ exports[`Search Results Page renders loading images before returning no results
}

.emotion-14 {
background-color: #fff;
box-shadow: 0 0 4px 0 rgba(231, 238, 236, 0.4);
background-color: #fff;
height: 152px;
position: relative;
place-self: center;
Expand Down Expand Up @@ -3162,8 +3139,8 @@ exports[`Search Results Page renders loading images before returning nonempty re
}

.emotion-14 {
background-color: #fff;
box-shadow: 0 0 4px 0 rgba(231, 238, 236, 0.4);
background-color: #fff;
height: 152px;
position: relative;
place-self: center;
Expand Down Expand Up @@ -3955,8 +3932,8 @@ exports[`Search Results Page renders results from a given search term query para
-webkit-text-decoration: none;
text-decoration: none;
border-radius: 24px;
background-color: #fff;
box-shadow: 0 0 4px 0 rgba(231, 238, 236, 0.4);
background-color: #fff;
height: 152px;
position: relative;
place-self: center;
Expand Down Expand Up @@ -4005,20 +3982,6 @@ exports[`Search Results Page renders results from a given search term query para

.emotion-17 {
height: 100%;
position: relative;
}

@media only screen and (max-width: 480px) {
.emotion-17 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
height: 100%;
}
bianca-laube marked this conversation as resolved.
Show resolved Hide resolved
}

.emotion-19 {
Expand All @@ -4035,24 +3998,15 @@ exports[`Search Results Page renders results from a given search term query para
overflow: hidden;
font-size: 16px;
line-height: 24px;
}

@media not all and (max-width: 480px) {
.emotion-19 {
font-weight: 600;
}
font-weight: 600;
position: relative;
}

@media only screen and (max-width: 480px) {
.emotion-19 {
font-size: 16px;
line-height: 24px;
}

@media not all and (max-width: 480px) {
.emotion-19 {
font-weight: 600;
}
font-weight: 600;
bianca-laube marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading