MCPcopy Create free account
hub / github.com/dailydotdev/apps / SearchControlHeader

Function SearchControlHeader

packages/shared/src/components/layout/common.tsx:64–276  ·  view source on GitHub ↗
({
  feedName,
  algoState: [selectedAlgo, setSelectedAlgo],
  chips,
}: SearchControlHeaderProps)

Source from the content-addressed store, hash-verified

62export const DEFAULT_ALGORITHM_INDEX = 0;
63
64export const SearchControlHeader = ({
65 feedName,
66 algoState: [selectedAlgo, setSelectedAlgo],
67 chips,
68}: SearchControlHeaderProps): ReactElement | null => {
69 const [selectedPeriod, setSelectedPeriod] = useQueryState({
70 key: [QueryStateKeys.FeedPeriod],
71 defaultValue: 0,
72 });
73 const { sortingEnabled } = useContext(SettingsContext);
74 const { isUpvoted, isSortableFeed } = useFeedName({ feedName });
75 const isMobile = useViewSize(ViewSize.MobileL);
76 const isLaptopLayout = useLaptopLayout();
77 const { streak, isLoading, isStreaksEnabled } = useReadingStreak();
78 const feedsWithActions = [
79 SharedFeedPage.MyFeed,
80 SharedFeedPage.Custom,
81 SharedFeedPage.CustomForm,
82 ];
83 const hasFeedActions = feedsWithActions.includes(feedName as SharedFeedPage);
84
85 if (isMobile) {
86 return null;
87 }
88
89 // v2 compact ghost styles for the page-header action strip: 32px
90 // square icon buttons + 32px-tall text buttons, no border/bg, with
91 // a surface-hover affordance on hover.
92 const compactIconButtonClassName =
93 '!size-8 !rounded-10 !border-transparent !bg-transparent !p-0 hover:!bg-surface-hover';
94 const compactTextButtonClassName =
95 '!h-8 !rounded-10 !border-transparent !bg-transparent !px-3 hover:!bg-surface-hover';
96
97 const dropdownProps: Partial<DropdownProps> = {
98 className: {
99 label: 'hidden',
100 chevron: 'hidden',
101 button: isLaptopLayout ? compactIconButtonClassName : '!px-1',
102 container: 'flex',
103 },
104 shouldIndicateSelected: true,
105 buttonSize: isLaptopLayout ? ButtonSize.Small : ButtonSize.Medium,
106 iconOnly: true,
107 buttonVariant: ButtonVariant.Tertiary,
108 };
109
110 const dropdownIconSize = isLaptopLayout ? IconSize.XSmall : IconSize.Medium;
111 // With chips the actions collapse to icons so the strip fits on one row.
112 const hasV2Chips = isLaptopLayout && !!chips;
113 const compactActionClassName = hasV2Chips
114 ? compactIconButtonClassName
115 : compactTextButtonClassName;
116 const primaryActions = [
117 feedName === SharedFeedPage.MyFeed && (
118 <FeedExplainSwitch
119 key="explain"
120 isRecommended={selectedAlgo === DEFAULT_ALGORITHM_INDEX}
121 iconOnly={hasV2Chips}

Callers

nothing calls this directly

Calls 5

useQueryStateFunction · 0.90
useFeedNameFunction · 0.90
useViewSizeFunction · 0.90
useLaptopLayoutFunction · 0.90
useReadingStreakFunction · 0.90

Tested by

no test coverage detected