From 02d7ebce910a95a5d30065eb355615a6ca65908a Mon Sep 17 00:00:00 2001
From: Keegan Kavanagh
Date: Thu, 25 Aug 2022 15:08:52 -0700
Subject: [PATCH 01/13] working and has storybook and styles
---
packages/search-package/.gitignore | 2 +
packages/search-package/.storybook/main.js | 39 ++++++
.../.storybook/preview-head.html | 1 +
packages/search-package/.storybook/preview.js | 24 ++++
packages/search-package/CHANGELOG.md | 65 ++++++++++
packages/search-package/README.md | 26 ++++
packages/search-package/package.json | 84 ++++++++++++
.../src/components/Search/Results.stories.tsx | 64 ++++++++++
.../src/components/Search/Results.tsx | 112 ++++++++++++++++
.../src/components/Search/Search.stories.tsx | 19 +++
.../src/components/Search/Search.tsx | 114 +++++++++++++++++
.../src/components/Search/SearchFunctions.ts | 35 +++++
.../src/components/Search/SearchStyles.tsx | 73 +++++++++++
.../src/components/Search/UseSearch.tsx | 110 ++++++++++++++++
.../components/SmallViews/BreadcrumbLink.tsx | 30 +++++
.../SmallViews/ItemView.stories.tsx | 29 +++++
.../src/components/SmallViews/ItemView.tsx | 74 +++++++++++
packages/search-package/src/index.d.ts | 0
packages/search-package/src/index.ts | 6 +
packages/search-package/src/styles.css | 120 ++++++++++++++++++
packages/search-package/tsconfig.json | 35 +++++
21 files changed, 1062 insertions(+)
create mode 100644 packages/search-package/.gitignore
create mode 100644 packages/search-package/.storybook/main.js
create mode 100644 packages/search-package/.storybook/preview-head.html
create mode 100644 packages/search-package/.storybook/preview.js
create mode 100644 packages/search-package/CHANGELOG.md
create mode 100644 packages/search-package/README.md
create mode 100644 packages/search-package/package.json
create mode 100644 packages/search-package/src/components/Search/Results.stories.tsx
create mode 100644 packages/search-package/src/components/Search/Results.tsx
create mode 100644 packages/search-package/src/components/Search/Search.stories.tsx
create mode 100644 packages/search-package/src/components/Search/Search.tsx
create mode 100644 packages/search-package/src/components/Search/SearchFunctions.ts
create mode 100644 packages/search-package/src/components/Search/SearchStyles.tsx
create mode 100644 packages/search-package/src/components/Search/UseSearch.tsx
create mode 100644 packages/search-package/src/components/SmallViews/BreadcrumbLink.tsx
create mode 100644 packages/search-package/src/components/SmallViews/ItemView.stories.tsx
create mode 100644 packages/search-package/src/components/SmallViews/ItemView.tsx
create mode 100644 packages/search-package/src/index.d.ts
create mode 100644 packages/search-package/src/index.ts
create mode 100644 packages/search-package/src/styles.css
create mode 100644 packages/search-package/tsconfig.json
diff --git a/packages/search-package/.gitignore b/packages/search-package/.gitignore
new file mode 100644
index 0000000000..430675afe5
--- /dev/null
+++ b/packages/search-package/.gitignore
@@ -0,0 +1,2 @@
+dist/
+.out/
diff --git a/packages/search-package/.storybook/main.js b/packages/search-package/.storybook/main.js
new file mode 100644
index 0000000000..67ff1d56aa
--- /dev/null
+++ b/packages/search-package/.storybook/main.js
@@ -0,0 +1,39 @@
+module.exports = {
+ stories: ["../src/components/**/*.stories.@(js|jsx|ts|tsx|mdx)"],
+ addons: [
+ {
+ name: "@storybook/addon-docs",
+ options: {
+ configureJSX: true,
+ babelOptions: {},
+ sourceLoaderOptions: null,
+ transcludeMarkdown: true
+ }
+ }
+ ],
+ babel: async (options) => ({
+ ...options,
+
+ "plugins": [
+ "@babel/plugin-proposal-optional-chaining",
+ "@babel/plugin-transform-runtime",
+ ]
+ }),
+ webpackFinal: async (config) => {
+ config.module.rules[0].use[0].options.plugins[1] = [
+ '@babel/plugin-proposal-class-properties',
+ { loose: true }
+ ]
+
+ config.module.rules.push({
+ test: /\.(stories|story)\.[tj]sx?$/,
+ loader: require.resolve("@storybook/source-loader"),
+ exclude: [/node_modules/],
+ enforce: "pre"
+ });
+
+ config.resolve.extensions.push(".ts", ".tsx", ".mdx")
+
+ return config
+ }
+}
diff --git a/packages/search-package/.storybook/preview-head.html b/packages/search-package/.storybook/preview-head.html
new file mode 100644
index 0000000000..a05ce31fa3
--- /dev/null
+++ b/packages/search-package/.storybook/preview-head.html
@@ -0,0 +1 @@
+
diff --git a/packages/search-package/.storybook/preview.js b/packages/search-package/.storybook/preview.js
new file mode 100644
index 0000000000..cdb3a20801
--- /dev/null
+++ b/packages/search-package/.storybook/preview.js
@@ -0,0 +1,24 @@
+import { DocsPage, DocsContainer } from "@storybook/addon-docs";
+import { GlobalStyle } from '@saasquatch/visual-dev';
+import React from "react";
+
+export const parameters = {
+ docs: {
+ container: DocsContainer,
+ page: DocsPage,
+ },
+ options: {
+ enableShortcuts: false,
+ },
+ viewMode: "docs",
+};
+
+const withGlobalStyles = (Story, context) => {
+ return (
+ <>
+
+
+ >
+ );
+};
+export const decorators = [withGlobalStyles];
diff --git a/packages/search-package/CHANGELOG.md b/packages/search-package/CHANGELOG.md
new file mode 100644
index 0000000000..aaedbe54f3
--- /dev/null
+++ b/packages/search-package/CHANGELOG.md
@@ -0,0 +1,65 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [Unreleased]
+
+## [1.0.2] - 2022-08-02
+
+### Changed
+
+- Update global CSS variables to match new portal design system variables
+
+## [1.0.1] - 2022-07-21
+
+### Changed
+
+- Fix icons in safari by adding width to svg
+- Make Modal buttons more configurable
+- More SVG icon options added
+- Remove stopPropagation from select list to prevent conflict with Popper.js
+
+### Added
+
+## [1.0.0] - 2022-06-01
+
+### Added
+
+- New visual-dev components:
+ - \
+ - \
+ - \
+ - \
+ - \
+ - \
)}
-
+
{queries?.previousPage && (
props.setStartIndex(queries.previousPage[0].startIndex)}
+ onClick={() =>
+ props.setStartIndex(queries.previousPage[0].startIndex)
+ }
>
Previous
)}
{queries?.nextPage && (
- props.setStartIndex(queries.nextPage[0].startIndex)}>
+ props.setStartIndex(queries.nextPage[0].startIndex)}
+ >
Next
)}
- {!items && props.onIsBlank(props.query) && (
+ {!props.sidebar && !items && props.onIsBlank(props.query) && (
What are you looking for?
diff --git a/packages/search-package/src/components/Search/Search.stories.tsx b/packages/search-package/src/components/Search/Search.stories.tsx
index 1248e82983..3808dcbfa4 100644
--- a/packages/search-package/src/components/Search/Search.stories.tsx
+++ b/packages/search-package/src/components/Search/Search.stories.tsx
@@ -17,3 +17,14 @@ export const Default = () => {
return ;
};
+
+export const MiniSearch = () => {
+ const miniProps: SearchProps = {
+ onGetBreadcrumbs: getBreadcrumb,
+ onIsBlank: isBlank,
+ useSearch: useSearch(),
+ sidebar: true
+ }
+
+ return ;
+};
diff --git a/packages/search-package/src/components/Search/Search.tsx b/packages/search-package/src/components/Search/Search.tsx
index 712eb932de..9f15411523 100644
--- a/packages/search-package/src/components/Search/Search.tsx
+++ b/packages/search-package/src/components/Search/Search.tsx
@@ -4,8 +4,8 @@ import { InputView, RadioView } from "@saasquatch/visual-dev";
import { Results } from "./Results";
import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
-const SearchContainerDiv = styled.div`
- max-width: 1000px;
+const SearchContainerDiv = styled.div<{sidebar?: boolean}>`
+ max-width: ${(props) => (props.sidebar ? "300px" : "1000px")};
`;
const RadioContainerDiv = styled.div`
@@ -24,7 +24,7 @@ export interface useSearchProps {
export interface SearchProps {
/**
- * Pass in getBreadcrum function, or a function to create a breadcrumb changed
+ * Pass in getBreadcrum function, or a function to create a breadcrumb changed
*/
onGetBreadcrumbs: (link: string) => Array;
/**
@@ -35,63 +35,78 @@ export interface SearchProps {
* Pass in useSearch function in here
*/
useSearch: useSearchProps;
+ /**
+ * If sidebar is true, it'll be mini and remove radio buttons
+ */
+ sidebar?: boolean;
}
export default function Search(props: SearchProps) {
if (typeof document === "undefined") {
return ;
}
+ console.log(props.sidebar);
return (
<>
-
Help Center Search
+ {!props.sidebar &&Help Center Search
}
- {!props.useSearch.response && (
+ {!props.sidebar && !props.useSearch.response && (
Searching Help Center...
@@ -112,6 +127,7 @@ export default function Search(props: SearchProps) {
query={props.useSearch.query}
onGetBreadcrumbs={props.onGetBreadcrumbs}
onIsBlank={props.onIsBlank}
+ sidebar={props.sidebar}
/>
)}
From d601db9df7a814fdb27c87a88e5434ec517fca6d Mon Sep 17 00:00:00 2001
From: Keegan Kavanagh
Date: Mon, 29 Aug 2022 17:05:52 -0700
Subject: [PATCH 09/13] exporting searchprops
---
packages/search-package/package.json | 2 +-
packages/search-package/src/index.ts | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/packages/search-package/package.json b/packages/search-package/package.json
index 5370a7f918..cc92676f92 100644
--- a/packages/search-package/package.json
+++ b/packages/search-package/package.json
@@ -1,6 +1,6 @@
{
"name": "@saasquatch/squatch-search",
- "version": "0.1.0-9",
+ "version": "0.1.0-10",
"description": "SaaSquatch search",
"main": "dist/index.js",
"module": "dist/visual-dev.esm.js",
diff --git a/packages/search-package/src/index.ts b/packages/search-package/src/index.ts
index 530cce96a7..e14d44123f 100644
--- a/packages/search-package/src/index.ts
+++ b/packages/search-package/src/index.ts
@@ -1,4 +1,4 @@
-import Search from './components/Search/Search';
+import Search, { SearchProps } from './components/Search/Search';
import { getBreadcrumb, isBlank } from './components/Search/SearchFunctions';
import { useSearch } from './components/Search/UseSearch';
///
@@ -7,5 +7,6 @@ export {
Search,
getBreadcrumb,
isBlank,
- useSearch
+ useSearch,
+ SearchProps
};
From afe9733d400baf00ed4747f0c4203df89a2bcb4e Mon Sep 17 00:00:00 2001
From: Keegan Kavanagh
Date: Tue, 30 Aug 2022 10:08:20 -0700
Subject: [PATCH 10/13] making sidebar mandatory in searchprops
---
packages/search-package/package.json | 2 +-
packages/search-package/src/components/Search/Results.tsx | 6 +++---
.../search-package/src/components/Search/Search.stories.tsx | 3 ++-
packages/search-package/src/components/Search/Search.tsx | 4 ++--
4 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/packages/search-package/package.json b/packages/search-package/package.json
index cc92676f92..ac37963344 100644
--- a/packages/search-package/package.json
+++ b/packages/search-package/package.json
@@ -1,6 +1,6 @@
{
"name": "@saasquatch/squatch-search",
- "version": "0.1.0-10",
+ "version": "0.1.0-11",
"description": "SaaSquatch search",
"main": "dist/index.js",
"module": "dist/visual-dev.esm.js",
diff --git a/packages/search-package/src/components/Search/Results.tsx b/packages/search-package/src/components/Search/Results.tsx
index c03d926b6b..5f7d1a9d4d 100644
--- a/packages/search-package/src/components/Search/Results.tsx
+++ b/packages/search-package/src/components/Search/Results.tsx
@@ -3,12 +3,12 @@ import styled from "styled-components";
import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
import ItemView from "../SmallViews/ItemView";
-const ItemsContainerDiv = styled.div<{sidebar?: boolean}>`
+const ItemsContainerDiv = styled.div<{sidebar: boolean}>`
max-width: ${(props) => (props.sidebar ? "300px" : "1000px")};
margin-top: var(--sq-spacing-large);
`;
-const PrevNextDiv = styled.div<{ sidebar?: boolean }>`
+const PrevNextDiv = styled.div<{ sidebar: boolean }>`
max-width: ${(props) => (props.sidebar ? "300px" : "1000px")};
display: flex;
flex-direction: row;
@@ -48,7 +48,7 @@ export interface ResultsProps {
query: string;
onGetBreadcrumbs: (link: string) => Array;
onIsBlank: (str?: string) => boolean;
- sidebar?: boolean;
+ sidebar: boolean;
}
// @ts-ignore
diff --git a/packages/search-package/src/components/Search/Search.stories.tsx b/packages/search-package/src/components/Search/Search.stories.tsx
index 3808dcbfa4..89419eb0a6 100644
--- a/packages/search-package/src/components/Search/Search.stories.tsx
+++ b/packages/search-package/src/components/Search/Search.stories.tsx
@@ -12,7 +12,8 @@ export const Default = () => {
const defaultProps: SearchProps = {
onGetBreadcrumbs: getBreadcrumb,
onIsBlank: isBlank,
- useSearch: useSearch()
+ useSearch: useSearch(),
+ sidebar: false
}
return ;
diff --git a/packages/search-package/src/components/Search/Search.tsx b/packages/search-package/src/components/Search/Search.tsx
index 9f15411523..1fb3d0639f 100644
--- a/packages/search-package/src/components/Search/Search.tsx
+++ b/packages/search-package/src/components/Search/Search.tsx
@@ -4,7 +4,7 @@ import { InputView, RadioView } from "@saasquatch/visual-dev";
import { Results } from "./Results";
import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
-const SearchContainerDiv = styled.div<{sidebar?: boolean}>`
+const SearchContainerDiv = styled.div<{sidebar: boolean}>`
max-width: ${(props) => (props.sidebar ? "300px" : "1000px")};
`;
@@ -38,7 +38,7 @@ export interface SearchProps {
/**
* If sidebar is true, it'll be mini and remove radio buttons
*/
- sidebar?: boolean;
+ sidebar: boolean;
}
export default function Search(props: SearchProps) {
From a212e2f45decfa9f0e655bc6f9826e46a12614f3 Mon Sep 17 00:00:00 2001
From: Keegan Kavanagh
Date: Tue, 30 Aug 2022 16:40:20 -0700
Subject: [PATCH 11/13] added styling
---
packages/search-package/package.json | 2 +-
.../src/components/Search/Results.tsx | 35 +++++++++++------
.../src/components/Search/Search.tsx | 39 ++++++++++++-------
3 files changed, 50 insertions(+), 26 deletions(-)
diff --git a/packages/search-package/package.json b/packages/search-package/package.json
index ac37963344..89240c2334 100644
--- a/packages/search-package/package.json
+++ b/packages/search-package/package.json
@@ -1,6 +1,6 @@
{
"name": "@saasquatch/squatch-search",
- "version": "0.1.0-11",
+ "version": "0.1.0-13",
"description": "SaaSquatch search",
"main": "dist/index.js",
"module": "dist/visual-dev.esm.js",
diff --git a/packages/search-package/src/components/Search/Results.tsx b/packages/search-package/src/components/Search/Results.tsx
index 5f7d1a9d4d..a74d8fb106 100644
--- a/packages/search-package/src/components/Search/Results.tsx
+++ b/packages/search-package/src/components/Search/Results.tsx
@@ -3,13 +3,24 @@ import styled from "styled-components";
import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
import ItemView from "../SmallViews/ItemView";
-const ItemsContainerDiv = styled.div<{sidebar: boolean}>`
- max-width: ${(props) => (props.sidebar ? "300px" : "1000px")};
+const ItemsContainerDiv = styled.div<{sidebar: boolean, query: string}>`
+ max-width: ${(props) => (props.sidebar ? "470px" : "1000px")};
margin-top: var(--sq-spacing-large);
+ min-height: ${(props) => (props.query && props.sidebar && "20px")};
+ padding: ${(props) => (props.query && props.sidebar && "19px;")};
+ margin-bottom: ${(props) => (props.query && props.sidebar && "20px;")};
+ background-color: ${(props) => (props.query && props.sidebar && "#f5f5f5;")};
+ border: ${(props) => (props.query && props.sidebar && "1px solid #e3e3e3;")};
+ -webkit-border-radius: ${(props) => (props.query && props.sidebar && "4px;")};
+ -moz-border-radius: ${(props) => (props.query && props.sidebar && "4px;")};
+ border-radius: ${(props) => (props.query && props.sidebar && "4px;")};
+ -webkit-box-shadow: ${(props) => (props.query && props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ -moz-box-shadow: ${(props) => (props.query && props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ box-shadow: ${(props) => (props.query && props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
`;
const PrevNextDiv = styled.div<{ sidebar: boolean }>`
- max-width: ${(props) => (props.sidebar ? "300px" : "1000px")};
+ max-width: ${(props) => (props.sidebar ? "470px" : "1000px")};
display: flex;
flex-direction: row;
justify-content: ${(props) => (props.sidebar ? "right" : "center")};
@@ -56,9 +67,10 @@ export function Results(props: ResultsProps) {
const { items, queries, searchInformation } = props.response;
console.log(props.response);
+ console.log("query: ", props.query)
return (
<>
-
+
{items &&
items
// @ts-ignore
@@ -73,9 +85,7 @@ export function Results(props: ResultsProps) {
/>
))}
-
-
- {items && (
+ {items && (
{searchInformation.totalResults} total results found in{" "}
{searchInformation.formattedSearchTime} seconds
@@ -102,21 +112,22 @@ export function Results(props: ResultsProps) {
{!props.sidebar && !items && props.onIsBlank(props.query) && (
-
-
What are you looking for?
+
+
What are you looking for?
)}
{!items && !props.onIsBlank(props.query) && (
-
-
+
+
No matching Docs!
-
+
Looks like we couldn't find any Help Center page that matches your
search term "{props.query}"
)}
+
>
);
}
diff --git a/packages/search-package/src/components/Search/Search.tsx b/packages/search-package/src/components/Search/Search.tsx
index 1fb3d0639f..2eddddbbd1 100644
--- a/packages/search-package/src/components/Search/Search.tsx
+++ b/packages/search-package/src/components/Search/Search.tsx
@@ -5,7 +5,7 @@ import { Results } from "./Results";
import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
const SearchContainerDiv = styled.div<{sidebar: boolean}>`
- max-width: ${(props) => (props.sidebar ? "300px" : "1000px")};
+ max-width: ${(props) => (props.sidebar ? "470px" : "1000px")};
`;
const RadioContainerDiv = styled.div`
@@ -13,6 +13,21 @@ const RadioContainerDiv = styled.div`
flex-direction: row;
`;
+const WellDiv = styled.div<{sidebar: boolean}>`
+ min-height: ${(props) => (!props.sidebar && "20px")};
+ padding: ${(props) => (!props.sidebar && "19px;")};
+ text-align: center;
+ margin-bottom: ${(props) => (!props.sidebar && "20px;")};
+ background-color: ${(props) => (!props.sidebar && "#f5f5f5;")};
+ border: ${(props) => (!props.sidebar && "1px solid #e3e3e3;")};
+ -webkit-border-radius: ${(props) => (!props.sidebar && "4px;")};
+ -moz-border-radius: ${(props) => (!props.sidebar && "4px;")};
+ border-radius: ${(props) => (!props.sidebar && "4px;")};
+ -webkit-box-shadow: ${(props) => (!props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ -moz-box-shadow: ${(props) => (!props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ box-shadow: ${(props) => (!props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+`
+
export interface useSearchProps {
response: any;
query: string;
@@ -48,11 +63,10 @@ export default function Search(props: SearchProps) {
console.log(props.sidebar);
return (
<>
-
-
-
- {!props.sidebar &&
Help Center Search
}
-
-
-
+
+
{!props.sidebar && !props.useSearch.response && (
-
+
Searching Help Center...
-
+
)}
{/* @ts-ignore */}
{props.useSearch.response && props.useSearch.response.error && (
-
+
{/* @ts-ignore */}
{props.useSearch.response.error.message}
@@ -132,7 +145,7 @@ export default function Search(props: SearchProps) {
)}
-
+
>
);
From 1e91c2f3311451f9316d9352ba99f14bb55218d4 Mon Sep 17 00:00:00 2001
From: Keegan Kavanagh
Date: Wed, 31 Aug 2022 10:58:45 -0700
Subject: [PATCH 12/13] removed breadcrumb and added optional backgrounds
---
packages/search-package/package.json | 2 +-
.../src/components/Search/Results.stories.tsx | 3 +-
.../src/components/Search/Results.tsx | 37 +++++++--------
.../src/components/Search/Search.stories.tsx | 28 +++++++++--
.../src/components/Search/Search.tsx | 46 +++++++++---------
.../src/components/Search/SearchFunctions.ts | 47 ++++++++++---------
.../src/components/SmallViews/ItemView.tsx | 16 +++----
packages/search-package/src/index.ts | 3 +-
8 files changed, 100 insertions(+), 82 deletions(-)
diff --git a/packages/search-package/package.json b/packages/search-package/package.json
index 89240c2334..efeecb1cd0 100644
--- a/packages/search-package/package.json
+++ b/packages/search-package/package.json
@@ -1,6 +1,6 @@
{
"name": "@saasquatch/squatch-search",
- "version": "0.1.0-13",
+ "version": "0.1.0-14",
"description": "SaaSquatch search",
"main": "dist/index.js",
"module": "dist/visual-dev.esm.js",
diff --git a/packages/search-package/src/components/Search/Results.stories.tsx b/packages/search-package/src/components/Search/Results.stories.tsx
index f61a445473..bc46997fa6 100644
--- a/packages/search-package/src/components/Search/Results.stories.tsx
+++ b/packages/search-package/src/components/Search/Results.stories.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { Results, ResultsProps } from "./Results";
-import { getBreadcrumb, isBlank } from "./SearchFunctions";
+import { isBlank } from "./SearchFunctions";
export default {
title: "Results",
@@ -55,7 +55,6 @@ const defaultProps: ResultsProps = {
},
setStartIndex: "",
query: "test",
- onGetBreadcrumbs: getBreadcrumb,
onIsBlank: isBlank,
};
diff --git a/packages/search-package/src/components/Search/Results.tsx b/packages/search-package/src/components/Search/Results.tsx
index a74d8fb106..f672583827 100644
--- a/packages/search-package/src/components/Search/Results.tsx
+++ b/packages/search-package/src/components/Search/Results.tsx
@@ -3,23 +3,23 @@ import styled from "styled-components";
import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
import ItemView from "../SmallViews/ItemView";
-const ItemsContainerDiv = styled.div<{sidebar: boolean, query: string}>`
+const ItemsContainerDiv = styled.div<{sidebar?: boolean, query: string, background?: boolean}>`
max-width: ${(props) => (props.sidebar ? "470px" : "1000px")};
margin-top: var(--sq-spacing-large);
- min-height: ${(props) => (props.query && props.sidebar && "20px")};
- padding: ${(props) => (props.query && props.sidebar && "19px;")};
- margin-bottom: ${(props) => (props.query && props.sidebar && "20px;")};
- background-color: ${(props) => (props.query && props.sidebar && "#f5f5f5;")};
- border: ${(props) => (props.query && props.sidebar && "1px solid #e3e3e3;")};
- -webkit-border-radius: ${(props) => (props.query && props.sidebar && "4px;")};
- -moz-border-radius: ${(props) => (props.query && props.sidebar && "4px;")};
- border-radius: ${(props) => (props.query && props.sidebar && "4px;")};
- -webkit-box-shadow: ${(props) => (props.query && props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
- -moz-box-shadow: ${(props) => (props.query && props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
- box-shadow: ${(props) => (props.query && props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ min-height: ${(props) => (props.background && props.query && props.sidebar && "20px")};
+ padding: ${(props) => (props.background && props.query && props.sidebar && "19px;")};
+ margin-bottom: ${(props) => (props.background && props.query && props.sidebar && "20px;")};
+ background-color: ${(props) => (props.background && props.query && props.sidebar && "#f5f5f5;")};
+ border: ${(props) => (props.background && props.query && props.sidebar && "1px solid #e3e3e3;")};
+ -webkit-border-radius: ${(props) => (props.background && props.query && props.sidebar && "4px;")};
+ -moz-border-radius: ${(props) => (props.background && props.query && props.sidebar && "4px;")};
+ border-radius: ${(props) => (props.background && props.query && props.sidebar && "4px;")};
+ -webkit-box-shadow: ${(props) => (props.background && props.query && props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ -moz-box-shadow: ${(props) => (props.background && props.query && props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ box-shadow: ${(props) => (props.background && props.query && props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
`;
-const PrevNextDiv = styled.div<{ sidebar: boolean }>`
+const PrevNextDiv = styled.div<{ sidebar?: boolean }>`
max-width: ${(props) => (props.sidebar ? "470px" : "1000px")};
display: flex;
flex-direction: row;
@@ -57,20 +57,20 @@ export interface ResultsProps {
response: any;
setStartIndex: any;
query: string;
- onGetBreadcrumbs: (link: string) => Array;
onIsBlank: (str?: string) => boolean;
- sidebar: boolean;
+ sidebar?: boolean;
+ background?: boolean;
+ linkComponent?: React.ReactNode;
}
// @ts-ignore
export function Results(props: ResultsProps) {
const { items, queries, searchInformation } = props.response;
- console.log(props.response);
+ const { background = true, linkComponent = ContainerA } = props;
- console.log("query: ", props.query)
return (
<>
-
+
{items &&
items
// @ts-ignore
@@ -81,7 +81,6 @@ export function Results(props: ResultsProps) {
))}
diff --git a/packages/search-package/src/components/Search/Search.stories.tsx b/packages/search-package/src/components/Search/Search.stories.tsx
index 89419eb0a6..592e2174d8 100644
--- a/packages/search-package/src/components/Search/Search.stories.tsx
+++ b/packages/search-package/src/components/Search/Search.stories.tsx
@@ -1,6 +1,6 @@
import React from "react";
import Search, { SearchProps } from "./Search";
-import { getBreadcrumb, isBlank } from './SearchFunctions'
+import { isBlank } from './SearchFunctions'
import { useSearch } from "./UseSearch";
export default {
@@ -10,10 +10,18 @@ export default {
export const Default = () => {
const defaultProps: SearchProps = {
- onGetBreadcrumbs: getBreadcrumb,
onIsBlank: isBlank,
useSearch: useSearch(),
- sidebar: false
+ background: true
+ }
+
+ return ;
+};
+
+export const NoBackground = () => {
+ const defaultProps: SearchProps = {
+ onIsBlank: isBlank,
+ useSearch: useSearch(),
}
return ;
@@ -21,10 +29,20 @@ export const Default = () => {
export const MiniSearch = () => {
const miniProps: SearchProps = {
- onGetBreadcrumbs: getBreadcrumb,
onIsBlank: isBlank,
useSearch: useSearch(),
- sidebar: true
+ sidebar: true,
+ }
+
+ return ;
+};
+
+export const MiniSearchNoBackground = () => {
+ const miniProps: SearchProps = {
+ onIsBlank: isBlank,
+ useSearch: useSearch(),
+ sidebar: true,
+ background: false
}
return ;
diff --git a/packages/search-package/src/components/Search/Search.tsx b/packages/search-package/src/components/Search/Search.tsx
index 2eddddbbd1..a10c5bf5ef 100644
--- a/packages/search-package/src/components/Search/Search.tsx
+++ b/packages/search-package/src/components/Search/Search.tsx
@@ -2,9 +2,8 @@ import React from "react";
import styled from "styled-components";
import { InputView, RadioView } from "@saasquatch/visual-dev";
import { Results } from "./Results";
-import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
-const SearchContainerDiv = styled.div<{sidebar: boolean}>`
+const SearchContainerDiv = styled.div<{sidebar?: boolean}>`
max-width: ${(props) => (props.sidebar ? "470px" : "1000px")};
`;
@@ -13,19 +12,19 @@ const RadioContainerDiv = styled.div`
flex-direction: row;
`;
-const WellDiv = styled.div<{sidebar: boolean}>`
- min-height: ${(props) => (!props.sidebar && "20px")};
- padding: ${(props) => (!props.sidebar && "19px;")};
+const WellDiv = styled.div<{sidebar?: boolean, background?: boolean}>`
+ min-height: ${(props) => (props.background && !props.sidebar && "20px")};
+ padding: ${(props) => (props.background && !props.sidebar && "19px;")};
text-align: center;
- margin-bottom: ${(props) => (!props.sidebar && "20px;")};
- background-color: ${(props) => (!props.sidebar && "#f5f5f5;")};
- border: ${(props) => (!props.sidebar && "1px solid #e3e3e3;")};
- -webkit-border-radius: ${(props) => (!props.sidebar && "4px;")};
- -moz-border-radius: ${(props) => (!props.sidebar && "4px;")};
- border-radius: ${(props) => (!props.sidebar && "4px;")};
- -webkit-box-shadow: ${(props) => (!props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
- -moz-box-shadow: ${(props) => (!props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
- box-shadow: ${(props) => (!props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ margin-bottom: ${(props) => (props.background && !props.sidebar && "20px;")};
+ background-color: ${(props) => (props.background && !props.sidebar && "#f5f5f5;")};
+ border: ${(props) => (props.background && !props.sidebar && "1px solid #e3e3e3;")};
+ -webkit-border-radius: ${(props) => (props.background && !props.sidebar && "4px;")};
+ -moz-border-radius: ${(props) => (props.background && !props.sidebar && "4px;")};
+ border-radius: ${(props) => (props.background && !props.sidebar && "4px;")};
+ -webkit-box-shadow: ${(props) => (props.background && !props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ -moz-box-shadow: ${(props) => (props.background && !props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
+ box-shadow: ${(props) => (props.background && !props.sidebar && "inset 0 1px 1px rgba(0, 0, 0, 0.05);")};
`
export interface useSearchProps {
@@ -38,10 +37,6 @@ export interface useSearchProps {
}
export interface SearchProps {
- /**
- * Pass in getBreadcrum function, or a function to create a breadcrumb changed
- */
- onGetBreadcrumbs: (link: string) => Array;
/**
* Pass in isBlank function to check if query is blank
*/
@@ -53,7 +48,15 @@ export interface SearchProps {
/**
* If sidebar is true, it'll be mini and remove radio buttons
*/
- sidebar: boolean;
+ sidebar?: boolean;
+ /**
+ * If this is true, the search will have a greyish background container - defaulted to true for sidebar
+ */
+ background?: boolean;
+ /**
+ *
+ */
+ linkComponent?: React.ReactNode;
}
export default function Search(props: SearchProps) {
@@ -64,7 +67,7 @@ export default function Search(props: SearchProps) {
return (
<>
-
+
{!props.sidebar && Help Center Search
}
@@ -138,9 +141,10 @@ export default function Search(props: SearchProps) {
response={props.useSearch.response}
setStartIndex={props.useSearch.setStartIndex}
query={props.useSearch.query}
- onGetBreadcrumbs={props.onGetBreadcrumbs}
onIsBlank={props.onIsBlank}
sidebar={props.sidebar}
+ background={props.background}
+ linkComponent={props.linkComponent}
/>
)}
diff --git a/packages/search-package/src/components/Search/SearchFunctions.ts b/packages/search-package/src/components/Search/SearchFunctions.ts
index 8c13674355..9229ff8c78 100644
--- a/packages/search-package/src/components/Search/SearchFunctions.ts
+++ b/packages/search-package/src/components/Search/SearchFunctions.ts
@@ -1,29 +1,30 @@
-import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
+// import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
export function isBlank(str?: string) {
return !str || /^\s*$/.test(str);
}
-export const getfullPath = (pathArray: Array
, index: number) => {
- let fullPath: string = "";
- for (let i = 0; i < index; i++) {
- fullPath = fullPath + pathArray[i] + "/";
- }
- return fullPath;
-};
+//Logan didn't want it - had non-existant saasquatch links
+// export const getfullPath = (pathArray: Array, index: number) => {
+// let fullPath: string = "";
+// for (let i = 0; i < index; i++) {
+// fullPath = fullPath + pathArray[i] + "/";
+// }
+// return fullPath;
+// };
-export const getBreadcrumb = (link: string) => {
- const fullPath: string = new URL(link).pathname;
- const noStartEndSlashes: string = fullPath.slice(1, -1);
- const pathArray: Array = noStartEndSlashes.split("/");
- const pathObjectsArray: Array = [];
- for (let i = 0; i < pathArray.length; i++) {
- const tempPathObject = {
- link: "https://docs.saasquatch.com/" + getfullPath(pathArray, i + 1),
- linkName:
- i + 1 === pathArray.length ? pathArray[i] : pathArray[i] + " > ",
- };
- pathObjectsArray.push(tempPathObject);
- }
- return pathObjectsArray;
-};
+// export const getBreadcrumb = (link: string) => {
+// const fullPath: string = new URL(link).pathname;
+// const noStartEndSlashes: string = fullPath.slice(1, -1);
+// const pathArray: Array = noStartEndSlashes.split("/");
+// const pathObjectsArray: Array = [];
+// for (let i = 0; i < pathArray.length; i++) {
+// const tempPathObject = {
+// link: "https://docs.saasquatch.com/" + getfullPath(pathArray, i + 1),
+// linkName:
+// i + 1 === pathArray.length ? pathArray[i] : pathArray[i] + " > ",
+// };
+// pathObjectsArray.push(tempPathObject);
+// }
+// return pathObjectsArray;
+// };
diff --git a/packages/search-package/src/components/SmallViews/ItemView.tsx b/packages/search-package/src/components/SmallViews/ItemView.tsx
index f443d3bb66..3abc2a4259 100644
--- a/packages/search-package/src/components/SmallViews/ItemView.tsx
+++ b/packages/search-package/src/components/SmallViews/ItemView.tsx
@@ -1,6 +1,5 @@
import React from "react";
import styled from "styled-components";
-import BreadcrumbLink, { BreadcrumbLinkProps } from "./BreadcrumbLink";
export interface ItemViewProps {
item: {
@@ -15,7 +14,6 @@ export interface ItemViewProps {
snippet: string;
title: string;
};
- onGetBreadcrumbs: (link: string) => Array;
}
const ItemContainerDiv = styled.div`
@@ -43,11 +41,11 @@ const DescriptionDiv = styled.div`
color: var(--sq-text);
`;
-const BreadcrumbContainerDiv = styled.div`
- display: row;
- flex-direction: column;
- margin-bottom: var(--sq-spacing-small);
-`;
+// const BreadcrumbContainerDiv = styled.div`
+// display: row;
+// flex-direction: column;
+// margin-bottom: var(--sq-spacing-small);
+// `;
const ItemView = (props: ItemViewProps) => {
return (
@@ -57,11 +55,11 @@ const ItemView = (props: ItemViewProps) => {
__html: props.item.htmlTitle,
}}
>
-
+ {/*
{props.onGetBreadcrumbs(props.item.link).map((item) => {
return ;
})}
-
+ */}
export {
Search,
- getBreadcrumb,
isBlank,
useSearch,
SearchProps
From 5b5afe275458d3c5fabd72e4e8368cf752f3c6c9 Mon Sep 17 00:00:00 2001
From: Keegan Kavanagh
Date: Wed, 31 Aug 2022 11:11:13 -0700
Subject: [PATCH 13/13] centered everything
---
packages/search-package/package.json | 2 +-
packages/search-package/src/components/Search/Results.tsx | 3 +--
packages/search-package/src/components/Search/Search.tsx | 3 +++
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/packages/search-package/package.json b/packages/search-package/package.json
index efeecb1cd0..277f750acb 100644
--- a/packages/search-package/package.json
+++ b/packages/search-package/package.json
@@ -1,6 +1,6 @@
{
"name": "@saasquatch/squatch-search",
- "version": "0.1.0-14",
+ "version": "0.1.0-16",
"description": "SaaSquatch search",
"main": "dist/index.js",
"module": "dist/visual-dev.esm.js",
diff --git a/packages/search-package/src/components/Search/Results.tsx b/packages/search-package/src/components/Search/Results.tsx
index f672583827..9c5adde0b4 100644
--- a/packages/search-package/src/components/Search/Results.tsx
+++ b/packages/search-package/src/components/Search/Results.tsx
@@ -1,6 +1,5 @@
import React from "react";
import styled from "styled-components";
-import { BreadcrumbLinkProps } from "../SmallViews/BreadcrumbLink";
import ItemView from "../SmallViews/ItemView";
const ItemsContainerDiv = styled.div<{sidebar?: boolean, query: string, background?: boolean}>`
@@ -66,7 +65,7 @@ export interface ResultsProps {
// @ts-ignore
export function Results(props: ResultsProps) {
const { items, queries, searchInformation } = props.response;
- const { background = true, linkComponent = ContainerA } = props;
+ const { background = true } = props;
return (
<>
diff --git a/packages/search-package/src/components/Search/Search.tsx b/packages/search-package/src/components/Search/Search.tsx
index a10c5bf5ef..a0f6953f47 100644
--- a/packages/search-package/src/components/Search/Search.tsx
+++ b/packages/search-package/src/components/Search/Search.tsx
@@ -5,6 +5,9 @@ import { Results } from "./Results";
const SearchContainerDiv = styled.div<{sidebar?: boolean}>`
max-width: ${(props) => (props.sidebar ? "470px" : "1000px")};
+ display: flex;
+ flex-direction: column;
+ align-items: center;
`;
const RadioContainerDiv = styled.div`