Skip to content

Commit

Permalink
Merge pull request #107 from medyo/develop
Browse files Browse the repository at this point in the history
Version 1.15.1
  • Loading branch information
medyo authored Dec 26, 2022
2 parents 8fd5c75 + dba66de commit 0d08b1e
Show file tree
Hide file tree
Showing 29 changed files with 547 additions and 318 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"axios-cache-adapter": "^2.7.3",
"country-emoji": "^1.5.4",
"dompurify": "^2.2.7",
"eslint-plugin-react": "^7.28.0",
"localforage": "^1.9.0",
"normalize.css": "^8.0.1",
"prop-types": "^15.0.0-0",
Expand All @@ -29,14 +30,14 @@
"react-scripts": "4.0.1",
"react-select": "^5.0.1",
"react-spinners": "^0.10.4",
"react-spring-bottom-sheet": "^3.4.1",
"react-toggle": "^4.1.1",
"react-tooltip": "^4.2.21",
"styled-components": "2",
"timeago.js": "^4.0.2",
"type-fest": "^1.2.0",
"web-vitals": "^0.2.4",
"zustand": "^4.1.3",
"eslint-plugin-react": "^7.28.0"
"zustand": "^4.1.3"
},
"proxy": "https://api.hackertab.dev/",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Hackertab.dev - developer news",
"description": "All developer news in one tab",
"version": "1.14.3",
"version": "1.15.1",
"manifest_version": 3,
"chrome_url_overrides": {
"newtab": "index.html"
Expand Down
65 changes: 54 additions & 11 deletions src/assets/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,6 @@ Producthunt item
position: relative;
}

.marketingBanner {
width: 48%;
margin: 0 auto;
margin-bottom: 16px;
}

.counterWrapper {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -701,7 +695,8 @@ Producthunt item
overflow-x: hidden !important;
}
.changelogButton {
width: 20px;
width: auto;
font-size: 12px;
height: 20px;
background-color: gray;
border-radius: 20px;
Expand All @@ -714,13 +709,11 @@ Producthunt item
border: 2px solid var(--background-color);
left: -6px;
top: -10px;
padding:0 4px;
text-transform: lowercase;
color: white;
}
.changelogButton.active {
width: auto;
font-size: 12px;
padding:0 4px;
text-transform: lowercase;
background-color: var(--tooltip-accent-color);
}
.changelogNewButton {
Expand Down Expand Up @@ -963,6 +956,34 @@ Producthunt item
margin-right: 16px;
border-radius: 4px;
}

.floatingFilter {
background: rgb(44, 128, 232);
border: transparent;
width: 48px;
height: 48px;
border-radius: 48px;
position: fixed;
bottom: 78px;
z-index: 2;
right: 32px;
display: none;
box-shadow: 0 2px 8px var(--card-actions-background-shadow);
}
.floatingFilterBottomSheet .title {
font-size: 22px;
margin:0 0 8px 0;
}

.floatingFilterIcon {
color: white;
font-size: 24px;
}
@media only screen and (max-width: 600px) {
.floatingFilter {
display: block
}
}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
.block {
Expand Down Expand Up @@ -1038,4 +1059,26 @@ Producthunt item
.Page .buttonIcon {
position: relative;
vertical-align: middle;
}


.chipsSet {
margin: 6px 0;
display: flex;
gap: 12px;
flex-wrap: wrap;
}

.chip {
font-weight: 500;
border-radius: 50px;
padding:6px 12px;
border: transparent;
font-family: "nunito";
color:var(--chip-text);
background-color: var(--chip-background);
}
.chip.active {
background-color: var(--chip-active-background);
color:var(--chip-active-text);
}
13 changes: 13 additions & 0 deletions src/assets/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ html.dark {
--tooltip-accent-color: #0366D6;

--placeholder-background-color: #1c2026;

--rsbs-bg: #0D1116;
--chip-background: #0D1116;
--chip-text: #FFF;
--chip-active-background: #576172;
--chip-active-text: #FFF;
}

html.light {
Expand Down Expand Up @@ -110,4 +116,11 @@ html.light {

--placeholder-background-color: #e7eff7;

--rsbs-bg: #fff;

--chip-background: #e7eff7;
--chip-text: #3C5065;
--chip-active-background: #0366D6;
--chip-active-text: #FFF;

}
10 changes: 3 additions & 7 deletions src/components/Elements/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ type CardProps = {
titleComponent?: React.ReactNode
fullBlock?: boolean
}
export const Card = ({
card: { link, icon, label },
titleComponent,
children,
fullBlock = false,
}: CardProps) => {
const { openLinksNewTab } = useUserPreferences()

export const Card = ({ card, titleComponent, children, fullBlock = false }: CardProps) => {
const { openLinksNewTab } = useUserPreferences()
const { link, icon, label } = card
const handleHeaderLinkClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
let url = `${link}?${ref}`
Expand Down
41 changes: 41 additions & 0 deletions src/components/Elements/ChipsSet/ChipsSet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Option } from 'src/types'
import { useState } from 'react'

type ChipProps = {
option: Option
onSelect: (option: Option) => void
active: boolean
}

const Chip = ({ option, onSelect, active = false }: ChipProps) => {
return (
<button className={'chip ' + (active && 'active')} onClick={() => onSelect(option)}>
{option.label}
</button>
)
}

type ChipsSetProps = {
options: Option[]
defaultValue: Option
onChange: (option: Option) => void
}

export const ChipsSet = ({ options, onChange, defaultValue }: ChipsSetProps) => {
const [selectedChip, setSelectedChip] = useState<Option>(defaultValue)

const onSelect = (option: Option) => {
setSelectedChip(option)
onChange(option)
}

return (
<div className="chipsSet">
{options.map((option) => {
return (
<Chip option={option} onSelect={onSelect} active={selectedChip.value === option.value} />
)
})}
</div>
)
}
1 change: 1 addition & 0 deletions src/components/Elements/ChipsSet/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./ChipsSet"
95 changes: 95 additions & 0 deletions src/components/Elements/FloatingFilter/FloatingFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { SupportedCard, GLOBAL_TAG, MY_LANGUAGES_TAG, dateRanges } from 'src/config'
import { FiFilter } from 'react-icons/fi'
import { useState } from 'react'
import { BottomSheet } from 'react-spring-bottom-sheet'
import 'react-spring-bottom-sheet/dist/style.css'
import { useUserPreferences } from 'src/stores/preferences'
import { trackCardLanguageSelect, trackCardDateRangeSelect } from 'src/lib/analytics'
import { ChipsSet } from 'src/components/Elements'

type ListingFilterMobileProps = {
card: SupportedCard
filters?: ('datesRange' | 'language')[]
}

export const FloatingFilter = ({ card, filters = ['language'] }: ListingFilterMobileProps) => {
const [open, setOpen] = useState(false)
const { userSelectedTags, cardsSettings, setCardSettings } = useUserPreferences()
const [availableTagOptions] = useState(
[GLOBAL_TAG, ...userSelectedTags, MY_LANGUAGES_TAG].map((tag) => ({
label: tag.label,
value: tag.value,
}))
)
return (
<>
<button
className="floatingFilter"
onClick={() => setOpen(true)}
style={open ? { display: 'none' } : {}}>
<FiFilter className="floatingFilterIcon" />
</button>

<BottomSheet
defaultSnap={({ maxHeight }) => maxHeight / 2}
open={open}
expandOnContentDrag={true}
onDismiss={() => setOpen(false)}>
<div style={{ padding: '16px' }}>
<div className="settings floatingFilterBottomSheet">
<h1 className="title">Customize {card.label}</h1>

{filters.includes('language') && (
<div className="settingRow">
<p className="settingTitle">Language</p>
<div className="settingContent">
<ChipsSet
defaultValue={
availableTagOptions.find(
(tag) => tag.value === cardsSettings[card.value]?.language
) || {
label: GLOBAL_TAG.label,
value: GLOBAL_TAG.value,
}
}
options={availableTagOptions}
onChange={(option) => {
setCardSettings(card.value, {
...cardsSettings[card.value],
language: option.value,
})
trackCardLanguageSelect(card.analyticsTag, option.value)
}}
/>
</div>
</div>
)}

{filters.includes('datesRange') && (
<div className="settingRow">
<p className="settingTitle">Date Range</p>
<div className="settingContent">
<ChipsSet
defaultValue={
dateRanges.find(
(date) => date.value === cardsSettings[card.value]?.dateRange
) || dateRanges[0]
}
options={dateRanges}
onChange={(option) => {
setCardSettings(card.value, {
...cardsSettings[card.value],
dateRange: option.value,
})
trackCardDateRangeSelect(card.analyticsTag, option.value)
}}
/>
</div>
</div>
)}
</div>
</div>
</BottomSheet>
</>
)
}
1 change: 1 addition & 0 deletions src/components/Elements/FloatingFilter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./FloatingFilter"
25 changes: 25 additions & 0 deletions src/components/Elements/InlineTextFilter/InlineTextFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import DropDownMenu from '../../DropDownMenu'

type Option = {
label: string
value: string
}
type InlineTextFilterProps = {
options: Option[]
value: string | undefined
onChange: (option: Option) => void
}

export const InlineTextFilter = ({ options, value, onChange }: InlineTextFilterProps) => {
const tagId = `inline-text-filter-${Math.random().toString(16).slice(2)}`
return (
<DropDownMenu
data={options}
tagId={tagId}
label={options.find((opt) => opt.value === value)?.label || options[0].label}
setSelectedDropDownItem={(item: Option) => {
onChange(item)
}}
/>
)
}
1 change: 1 addition & 0 deletions src/components/Elements/InlineTextFilter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./InlineTextFilter"
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export const MarketingBanner = ({ show, htmlContent }: MarketingBannerProps) =>
}
let cleanHtmlContent = DOMPurify.sanitize(htmlContent)

return <div className="marketingBanner" dangerouslySetInnerHTML={{ __html: cleanHtmlContent }} />
return <div dangerouslySetInnerHTML={{ __html: cleanHtmlContent }} />
}
3 changes: 2 additions & 1 deletion src/components/Elements/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const SearchBar = () => {
}

trackSearchEngineUse(usedSearchEngine.label)
window.open(`${usedSearchEngine.url}${target.keyword}`, '_self')
window.open(`${usedSearchEngine.url}${target.keyword.value}`, '_self')
}

useEffect(() => {
Expand All @@ -33,6 +33,7 @@ export const SearchBar = () => {
<input
ref={keywordsInputRef}
type="text"
name="keyword"
className="searchBarInput"
placeholder={`Search on ${usedSearchEngine.label}`}
/>
Expand Down
5 changes: 4 additions & 1 deletion src/components/Elements/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export * from "./UserTags"
export * from "./BottomNavigation"
export * from "./CardLink"
export * from "./CardWithActions"
export * from "./ClickableItem"
export * from "./ClickableItem"
export * from "./FloatingFilter"
export * from "./InlineTextFilter"
export * from "./ChipsSet"
Loading

0 comments on commit 0d08b1e

Please sign in to comment.