oddsgate-ds 1.0.197 → 1.0.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/molecules/CategoriesWrapper/CategoriesWrapper.component.d.ts +4 -0
- package/dist/cjs/types/components/molecules/CategoriesWrapper/CategoriesWrapper.interface.d.ts +5 -0
- package/dist/cjs/types/components/molecules/CategoriesWrapper/CategoriesWrapper.theme.d.ts +6 -0
- package/dist/cjs/types/components/molecules/CategoryIndex/CategoryIndex.component.d.ts +4 -0
- package/dist/cjs/types/components/molecules/CategoryIndex/CategoryIndex.interface.d.ts +5 -0
- package/dist/cjs/types/components/molecules/CategoryIndex/CategoryIndex.theme.d.ts +7 -0
- package/dist/cjs/types/components/molecules/SearchBar/SearchBar.component.d.ts +4 -0
- package/dist/cjs/types/components/molecules/SearchBar/SearchBar.interface.d.ts +6 -0
- package/dist/cjs/types/components/molecules/SearchBar/SearchBar.theme.d.ts +4 -0
- package/dist/cjs/types/components/organisms/Glossary/Glossary.component.d.ts +26 -0
- package/dist/cjs/types/components/organisms/Glossary/Glossary.themes.d.ts +9 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/molecules/CategoriesWrapper/CategoriesWrapper.component.d.ts +4 -0
- package/dist/esm/types/components/molecules/CategoriesWrapper/CategoriesWrapper.interface.d.ts +5 -0
- package/dist/esm/types/components/molecules/CategoriesWrapper/CategoriesWrapper.theme.d.ts +6 -0
- package/dist/esm/types/components/molecules/CategoryIndex/CategoryIndex.component.d.ts +4 -0
- package/dist/esm/types/components/molecules/CategoryIndex/CategoryIndex.interface.d.ts +5 -0
- package/dist/esm/types/components/molecules/CategoryIndex/CategoryIndex.theme.d.ts +7 -0
- package/dist/esm/types/components/molecules/SearchBar/SearchBar.component.d.ts +4 -0
- package/dist/esm/types/components/molecules/SearchBar/SearchBar.interface.d.ts +6 -0
- package/dist/esm/types/components/molecules/SearchBar/SearchBar.theme.d.ts +4 -0
- package/dist/esm/types/components/organisms/Glossary/Glossary.component.d.ts +26 -0
- package/dist/esm/types/components/organisms/Glossary/Glossary.themes.d.ts +9 -0
- package/package.json +1 -1
- package/src/components/atoms/LegalLinks/LegalLinks.component.tsx +3 -3
- package/src/components/atoms/LegalLinksDropdown/LegalLinksDropdown.theme.ts +2 -2
- package/src/components/molecules/AwardCard/AwardCard.theme.ts +1 -1
- package/src/components/molecules/CategoriesWrapper/CategoriesWrapper.component.tsx +33 -0
- package/src/components/molecules/CategoriesWrapper/CategoriesWrapper.interface.ts +4 -0
- package/src/components/molecules/CategoriesWrapper/CategoriesWrapper.stories.tsx +27 -0
- package/src/components/molecules/CategoriesWrapper/CategoriesWrapper.theme.ts +38 -0
- package/src/components/molecules/CategoryIndex/CategoryIndex.component.tsx +33 -0
- package/src/components/molecules/CategoryIndex/CategoryIndex.interface.ts +5 -0
- package/src/components/molecules/CategoryIndex/CategoryIndex.stories.tsx +23 -0
- package/src/components/molecules/CategoryIndex/CategoryIndex.theme.ts +27 -0
- package/src/components/molecules/SearchBar/SearchBar.component.tsx +30 -0
- package/src/components/molecules/SearchBar/SearchBar.interface.ts +5 -0
- package/src/components/molecules/SearchBar/SearchBar.stories.tsx +18 -0
- package/src/components/molecules/SearchBar/SearchBar.theme.ts +47 -0
- package/src/components/organisms/Glossary/Glossary.component.tsx +84 -0
- package/src/components/organisms/Glossary/Glossary.interface.ts +0 -0
- package/src/components/organisms/Glossary/Glossary.stories.tsx +278 -0
- package/src/components/organisms/Glossary/Glossary.themes.ts +27 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledCategoryWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
+
export declare const StyledCategorySeparator: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
|
+
export declare const StyledCategorySeparatorLine: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
5
|
+
export declare const StyledCategoryContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
6
|
+
export declare const StyledCategoryItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type ItemProps = {
|
|
3
|
+
isSelected?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const StyledGlossaryCategoryIndex: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
6
|
+
export declare const StyledGlossaryCategoryIndexItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ItemProps>> & string;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledGlossarySearch: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
+
export declare const SearchInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
|
|
4
|
+
export declare const SearchButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type GlossaryItem = {
|
|
3
|
+
title: string;
|
|
4
|
+
categories: {
|
|
5
|
+
name: string;
|
|
6
|
+
items: {
|
|
7
|
+
slug: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}[];
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
type GlossaryProps = {
|
|
13
|
+
title: string;
|
|
14
|
+
subtitle: string;
|
|
15
|
+
items: GlossaryItem[];
|
|
16
|
+
categories: {
|
|
17
|
+
name: string;
|
|
18
|
+
items: {
|
|
19
|
+
slug: string;
|
|
20
|
+
name: string;
|
|
21
|
+
}[];
|
|
22
|
+
}[];
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
};
|
|
25
|
+
declare const Glossary: React.FC<GlossaryProps>;
|
|
26
|
+
export default Glossary;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledGlossary: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
+
export declare const StyledGlossaryHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
|
+
export declare const StyledGlossaryTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
|
|
5
|
+
export declare const StyledGlossarySubtitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
|
|
6
|
+
export declare const StyledGlossaryIndex: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
7
|
+
export declare const StyledGlossaryCategories: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
8
|
+
export declare const StyledGlossarySeparator: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
9
|
+
export declare const StyledGlossaryCategoryItems: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>> & string;
|
package/package.json
CHANGED
|
@@ -18,12 +18,12 @@ const LegalLinks = ({
|
|
|
18
18
|
// If the link has children, render as dropdown
|
|
19
19
|
if (link.children && link.children.length > 0) {
|
|
20
20
|
return (
|
|
21
|
-
<li key={`
|
|
21
|
+
<li key={`legalLink-${index}`}>
|
|
22
22
|
<LegalLinksDropdown title={link.label} className="font-epilogue">
|
|
23
23
|
{link.children.map((childLink, childIndex) => {
|
|
24
24
|
if (!childLink.label || !childLink.url) return null
|
|
25
25
|
return (
|
|
26
|
-
<LegalLinksDropdownItem key={`
|
|
26
|
+
<LegalLinksDropdownItem key={`childLink-${childIndex}`}>
|
|
27
27
|
<a
|
|
28
28
|
href={childLink.url}
|
|
29
29
|
target="_blank"
|
|
@@ -45,7 +45,7 @@ const LegalLinks = ({
|
|
|
45
45
|
if (!link.url) return <></>
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
|
-
<li key={`
|
|
48
|
+
<li key={`legalLink-${index}`}>
|
|
49
49
|
<a
|
|
50
50
|
href={link.url}
|
|
51
51
|
target="_blank"
|
|
@@ -50,7 +50,7 @@ export const StyledLegalLinksDropdownTitle = styled.span`
|
|
|
50
50
|
`
|
|
51
51
|
|
|
52
52
|
export const StyledLegalLinksDropdownContainer = styled.ul.withConfig({
|
|
53
|
-
shouldForwardProp:
|
|
53
|
+
shouldForwardProp: prop => prop !== 'openUpward' && prop !== 'isVisible'
|
|
54
54
|
})<ILegalLinksDropdownContainer>`
|
|
55
55
|
position: absolute;
|
|
56
56
|
${props => (props.openUpward ? 'bottom: 100%;' : 'top: 100%;')}
|
|
@@ -172,7 +172,7 @@ export const StyledLegalLinksDropdownItem = styled.li<ILegalLinksDropdownItem>`
|
|
|
172
172
|
`
|
|
173
173
|
|
|
174
174
|
export const StyledLegalLinksDropdownIcon = styled.span.withConfig({
|
|
175
|
-
shouldForwardProp:
|
|
175
|
+
shouldForwardProp: prop => prop !== 'isOpen'
|
|
176
176
|
})<{ isOpen?: boolean }>`
|
|
177
177
|
font-size: 10px;
|
|
178
178
|
display: flex;
|
|
@@ -16,7 +16,7 @@ export const StyledAwardCardWrapper = styled.div<IAwardCard>`
|
|
|
16
16
|
justify-content: space-between;
|
|
17
17
|
gap: 1.125rem;
|
|
18
18
|
background-color: ${colors.third10};
|
|
19
|
-
padding:
|
|
19
|
+
padding: 1rem 0.75rem;
|
|
20
20
|
border-radius: 0 60px;
|
|
21
21
|
height: 100%;
|
|
22
22
|
`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
StyledCategoryContent,
|
|
4
|
+
StyledCategorySeparator,
|
|
5
|
+
StyledCategoryWrapper,
|
|
6
|
+
StyledCategoryItem,
|
|
7
|
+
StyledCategorySeparatorLine
|
|
8
|
+
} from './CategoriesWrapper.theme'
|
|
9
|
+
import { CategoriesWrapperProps } from './CategoriesWrapper.interface'
|
|
10
|
+
import Button from '@/components/atoms/Button'
|
|
11
|
+
|
|
12
|
+
const CategoriesWrapper: React.FC<CategoriesWrapperProps> = ({
|
|
13
|
+
category,
|
|
14
|
+
categoryItems
|
|
15
|
+
}) => {
|
|
16
|
+
return (
|
|
17
|
+
<StyledCategoryWrapper>
|
|
18
|
+
<StyledCategorySeparator>
|
|
19
|
+
{category}
|
|
20
|
+
<StyledCategorySeparatorLine />
|
|
21
|
+
</StyledCategorySeparator>
|
|
22
|
+
<StyledCategoryContent>
|
|
23
|
+
{categoryItems.map((item, index) => (
|
|
24
|
+
<StyledCategoryItem key={index}>
|
|
25
|
+
<Button variant="text">{item}</Button>
|
|
26
|
+
</StyledCategoryItem>
|
|
27
|
+
))}
|
|
28
|
+
</StyledCategoryContent>
|
|
29
|
+
</StyledCategoryWrapper>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default CategoriesWrapper;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
import CategoriesWrapper from './CategoriesWrapper.component'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof CategoriesWrapper> = {
|
|
6
|
+
title: 'Components/CategoriesWrapper',
|
|
7
|
+
component: CategoriesWrapper
|
|
8
|
+
}
|
|
9
|
+
export default meta
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof CategoriesWrapper>
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
category: 'A',
|
|
16
|
+
categoryItems: [
|
|
17
|
+
'Ace',
|
|
18
|
+
'Admin',
|
|
19
|
+
'AFK',
|
|
20
|
+
'Anti-eco',
|
|
21
|
+
'Aimbot',
|
|
22
|
+
'All-in',
|
|
23
|
+
'Armor',
|
|
24
|
+
'APM'
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { colors } from '@/styles/variables'
|
|
2
|
+
import styled from 'styled-components'
|
|
3
|
+
|
|
4
|
+
export const StyledCategoryWrapper = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
width: 100%;
|
|
8
|
+
`
|
|
9
|
+
|
|
10
|
+
export const StyledCategorySeparator = styled.div`
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
width: 100%;
|
|
14
|
+
gap: 0.75rem;
|
|
15
|
+
font-size: 3rem;
|
|
16
|
+
font-weight: 700;
|
|
17
|
+
`
|
|
18
|
+
export const StyledCategorySeparatorLine = styled.div`
|
|
19
|
+
flex-grow: 1;
|
|
20
|
+
height: 50%;
|
|
21
|
+
border-bottom: 1px solid ${colors.gray20};
|
|
22
|
+
opacity: 0.5;
|
|
23
|
+
`
|
|
24
|
+
|
|
25
|
+
export const StyledCategoryContent = styled.div`
|
|
26
|
+
display: flex;
|
|
27
|
+
gap: 1.875rem;
|
|
28
|
+
flex-wrap: wrap;
|
|
29
|
+
`
|
|
30
|
+
export const StyledCategoryItem = styled.div`
|
|
31
|
+
& > button {
|
|
32
|
+
height: 2.125rem;
|
|
33
|
+
padding: 0.625rem 2.5rem;
|
|
34
|
+
font-size: 1.5rem;
|
|
35
|
+
font-weight: 700;
|
|
36
|
+
text-transform: none;
|
|
37
|
+
}
|
|
38
|
+
`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
StyledGlossaryCategoryIndex,
|
|
4
|
+
StyledGlossaryCategoryIndexItem
|
|
5
|
+
} from './CategoryIndex.theme'
|
|
6
|
+
import { CategoryIndexProps } from './CategoryIndex.interface'
|
|
7
|
+
|
|
8
|
+
const CategoryIndex: React.FC<CategoryIndexProps> = ({
|
|
9
|
+
categories,
|
|
10
|
+
onChange,
|
|
11
|
+
selectedCategory
|
|
12
|
+
}) => {
|
|
13
|
+
const allCategories = ['#', ...categories]
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<StyledGlossaryCategoryIndex>
|
|
17
|
+
{allCategories.map(category => (
|
|
18
|
+
<StyledGlossaryCategoryIndexItem
|
|
19
|
+
onClick={() => onChange(category === '#' ? null : category)}
|
|
20
|
+
isSelected={
|
|
21
|
+
selectedCategory === category ||
|
|
22
|
+
(selectedCategory === null && category === '#')
|
|
23
|
+
}
|
|
24
|
+
key={`category-${category}`}
|
|
25
|
+
>
|
|
26
|
+
{category}
|
|
27
|
+
</StyledGlossaryCategoryIndexItem>
|
|
28
|
+
))}
|
|
29
|
+
</StyledGlossaryCategoryIndex>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default CategoryIndex
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import CategoryIndex from './CategoryIndex.component'
|
|
3
|
+
|
|
4
|
+
const categories = Array.from({ length: 26 }, (_, i) =>
|
|
5
|
+
String.fromCharCode(65 + i)
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Components/CategoryIndex',
|
|
10
|
+
component: CategoryIndex
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Default = () => {
|
|
14
|
+
const [selected, setSelected] = useState<string | null>(null)
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<CategoryIndex
|
|
18
|
+
categories={[...categories]}
|
|
19
|
+
selectedCategory={selected}
|
|
20
|
+
onChange={setSelected}
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { colors } from '@/styles/variables'
|
|
2
|
+
import styled from 'styled-components'
|
|
3
|
+
|
|
4
|
+
type ItemProps = {
|
|
5
|
+
isSelected?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const StyledGlossaryCategoryIndex = styled.div`
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
export const StyledGlossaryCategoryIndexItem = styled.div<ItemProps>`
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
border-radius: 100%;
|
|
16
|
+
background-color: ${({ isSelected }) =>
|
|
17
|
+
isSelected ? `${colors.primary50}66` : ''};
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
width: 2.125rem;
|
|
22
|
+
height: 2.125rem;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
color: ${colors.gray20};
|
|
25
|
+
font-weight: 700;
|
|
26
|
+
font-size: 1.5rem;
|
|
27
|
+
`
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
SearchButton,
|
|
4
|
+
SearchInput,
|
|
5
|
+
StyledGlossarySearch
|
|
6
|
+
} from './SearchBar.theme'
|
|
7
|
+
import Icon from '@/components/atoms/Icon'
|
|
8
|
+
import { SearchBarProps } from './SearchBar.interface'
|
|
9
|
+
|
|
10
|
+
const SearchBar: React.FC<SearchBarProps> = ({
|
|
11
|
+
value,
|
|
12
|
+
onChange,
|
|
13
|
+
placeholder
|
|
14
|
+
}) => {
|
|
15
|
+
return (
|
|
16
|
+
<StyledGlossarySearch>
|
|
17
|
+
<SearchInput
|
|
18
|
+
type="text"
|
|
19
|
+
placeholder={placeholder}
|
|
20
|
+
value={value}
|
|
21
|
+
onChange={onChange}
|
|
22
|
+
/>
|
|
23
|
+
<SearchButton>
|
|
24
|
+
<Icon icon="icon-search" />
|
|
25
|
+
</SearchButton>
|
|
26
|
+
</StyledGlossarySearch>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default SearchBar
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import SearchBar from './SearchBar.component'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Components/SearchBar',
|
|
6
|
+
component: SearchBar
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const Default = () => {
|
|
10
|
+
const [value, setValue] = useState('')
|
|
11
|
+
return (
|
|
12
|
+
<SearchBar
|
|
13
|
+
value={value}
|
|
14
|
+
onChange={e => setValue(e.target.value)}
|
|
15
|
+
placeholder="Search..."
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import { colors } from '@/styles/variables'
|
|
3
|
+
|
|
4
|
+
export const StyledGlossarySearch = styled.div`
|
|
5
|
+
position: relative;
|
|
6
|
+
width: 100%;
|
|
7
|
+
max-width: 870px;
|
|
8
|
+
margin: 2rem auto;
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
export const SearchInput = styled.input`
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
width: 100%;
|
|
15
|
+
padding: 1.5rem 0.75rem;
|
|
16
|
+
border-radius: 62.5rem;
|
|
17
|
+
border: none;
|
|
18
|
+
background: ${colors.gray20};
|
|
19
|
+
font-size: 0.9375rem;
|
|
20
|
+
color: ${colors.hellobar};
|
|
21
|
+
&::placeholder {
|
|
22
|
+
color: ${colors.hellobar};
|
|
23
|
+
}
|
|
24
|
+
`
|
|
25
|
+
|
|
26
|
+
export const SearchButton = styled.button`
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 50%;
|
|
29
|
+
transform: translateY(-50%);
|
|
30
|
+
right: 1.5rem;
|
|
31
|
+
width: 2.5rem;
|
|
32
|
+
height: 2.5rem;
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
background: ${colors.hellobar};
|
|
35
|
+
border: none;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
color: ${colors.gray20};
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
|
|
42
|
+
svg {
|
|
43
|
+
width: 1.25rem;
|
|
44
|
+
height: 1.25rem;
|
|
45
|
+
display: block;
|
|
46
|
+
}
|
|
47
|
+
`
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
StyledGlossary,
|
|
4
|
+
StyledGlossaryCategories,
|
|
5
|
+
StyledGlossarySubtitle,
|
|
6
|
+
StyledGlossaryTitle
|
|
7
|
+
} from './Glossary.themes'
|
|
8
|
+
|
|
9
|
+
import SearchBar from '@/components/molecules/SearchBar/SearchBar.component'
|
|
10
|
+
import GlossaryCategoryIndex from '@/components/molecules/CategoryIndex/CategoryIndex.component'
|
|
11
|
+
import CategoriesWrapper from '@/components/molecules/CategoriesWrapper/CategoriesWrapper.component'
|
|
12
|
+
|
|
13
|
+
type GlossaryItem = {
|
|
14
|
+
title: string
|
|
15
|
+
categories: { name: string, items: { slug: string, name: string }[] }[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type GlossaryProps = {
|
|
19
|
+
title: string
|
|
20
|
+
subtitle: string
|
|
21
|
+
items: GlossaryItem[]
|
|
22
|
+
categories: { name: string, items: { slug: string, name: string }[] }[]
|
|
23
|
+
placeholder?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const Glossary: React.FC<GlossaryProps> = ({
|
|
27
|
+
title,
|
|
28
|
+
subtitle,
|
|
29
|
+
items,
|
|
30
|
+
categories,
|
|
31
|
+
placeholder
|
|
32
|
+
}) => {
|
|
33
|
+
const [searchTerm, setSearchTerm] = useState('')
|
|
34
|
+
const [selectedCategory, setSelectedCategory] = useState<string | null>(null)
|
|
35
|
+
|
|
36
|
+
const categoryData: Record<string, string[]> = {}
|
|
37
|
+
categories[0].items.forEach(cat => {
|
|
38
|
+
categoryData[cat.name] = []
|
|
39
|
+
})
|
|
40
|
+
items.forEach(item => {
|
|
41
|
+
item.categories[0].items.forEach(cat => {
|
|
42
|
+
if (categoryData[cat.name]) {
|
|
43
|
+
categoryData[cat.name].push(item.title)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const categoryNames = Object.keys(categoryData)
|
|
49
|
+
|
|
50
|
+
const displayedCategories = selectedCategory
|
|
51
|
+
? [selectedCategory]
|
|
52
|
+
: categoryNames
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<StyledGlossary>
|
|
56
|
+
<StyledGlossaryTitle>{title}</StyledGlossaryTitle>
|
|
57
|
+
<StyledGlossarySubtitle>{subtitle}</StyledGlossarySubtitle>
|
|
58
|
+
|
|
59
|
+
<SearchBar
|
|
60
|
+
value={searchTerm}
|
|
61
|
+
onChange={e => setSearchTerm(e.target.value)}
|
|
62
|
+
placeholder="What are you looking for?"
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
<GlossaryCategoryIndex
|
|
66
|
+
categories={categoryNames}
|
|
67
|
+
selectedCategory={selectedCategory}
|
|
68
|
+
onChange={cat => setSelectedCategory(cat === selectedCategory ? null : cat)}
|
|
69
|
+
/>
|
|
70
|
+
|
|
71
|
+
<StyledGlossaryCategories>
|
|
72
|
+
{displayedCategories.map(category => (
|
|
73
|
+
<CategoriesWrapper
|
|
74
|
+
key={category}
|
|
75
|
+
category={category}
|
|
76
|
+
categoryItems={categoryData[category]}
|
|
77
|
+
/>
|
|
78
|
+
))}
|
|
79
|
+
</StyledGlossaryCategories>
|
|
80
|
+
</StyledGlossary>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default Glossary
|
|
File without changes
|