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

Function SearchControlHeader

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

Source from the content-addressed store, hash-verified

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

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