Skip to content

Commit

Permalink
Merge pull request #25 from PunitSoniME/feat/23-add-since-version
Browse files Browse the repository at this point in the history
feat(documentation): hook available since added
  • Loading branch information
PunitSoniME authored Jul 31, 2024
2 parents b0c45d6 + 7d618d6 commit 7f848c6
Show file tree
Hide file tree
Showing 57 changed files with 121 additions and 14 deletions.
11 changes: 9 additions & 2 deletions example/src/common/Documentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
const Title = lazy(() => import('@/common/Details/Title'));
const CodeSample = lazy(() => import('@/common/CodeSample'));

export default function Documentation({ hook, info, usage, children }: any) {
export default function Documentation({ hook, info, usage, version, children }: any) {
const [activeTab, setActiveTab] = useState('docs');

return (
<>
<Suspense fallback={<></>}>
<Title>{hook}</Title>
<div className='flex items-center gap-3'>
<Title>{hook}</Title>
{
version
? <code className='text-primary text-sm'>since v{version}</code>
: ""
}
</div>
</Suspense>

<Suspense fallback={<>Loading Code Block</>}>
Expand Down
4 changes: 1 addition & 3 deletions example/src/hooks/useArray/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { lazy, Suspense } from 'react';
import { packageName } from '@/lib/utils';
import Demo from './Demo';


const Documentation = lazy(() => import('@/common/Documentation'));

const hook = 'useArray';
Expand Down Expand Up @@ -35,10 +34,9 @@ export default function ArrayComponent() {
hook={hook}
info={info}
usage={usage}
version="1.0.0"
>

<Demo />

</Documentation>
</Suspense>
)
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useAsync/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function AsyncComponent() {
hook={hook}
info={info}
usage={usage}
version="1.1.0"
>
<Demo />
</Documentation>
Expand Down
3 changes: 1 addition & 2 deletions example/src/hooks/useAsyncLoop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ const { loading, value, error } = ${hook}(CALLBACK_FUNCTION, [DEPENDENCIES]);

export default function AsyncLoopComponent() {


return (
<Suspense fallback={<></>}>

<Documentation
hook={hook}
info={info}
usage={usage}
version="1.5.0"
>

<Demo />
</Documentation>

Expand Down
2 changes: 1 addition & 1 deletion example/src/hooks/useClickOutside/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const ref = ${hook}(CALLBACK_FUNCTION);

export default function ClickOutsideComponent() {


return (
<Suspense fallback={<></>}>

<Documentation
hook={hook}
info={info}
usage={usage}
version="1.12.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useColorBlend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function ColorBlendComponent() {
hook={hook}
info={info}
usage={usage}
version="1.6.0"
>

<Demo />
Expand Down
2 changes: 1 addition & 1 deletion example/src/hooks/useColorScheme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ const colorScheme = ${hook}();

export default function ColorSchemeComponent() {


return (
<Suspense fallback={<></>}>

<Documentation
hook={hook}
info={info}
usage={usage}
version="1.12.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useCopyToClipboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function CopyToClipboardComponent() {
hook={hook}
info={info}
usage={usage}
version="1.5.0"
>
<Demo />

Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useDebounce/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function UseDebounceComponent() {
hook={hook}
info={info}
usage={usage}
version="1.0.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useEventListener/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function EventListenerComponent() {
hook={hook}
info={info}
usage={usage}
version="1.2.0"
>
<Demo />

Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useFetch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function FetchComponent() {
hook={hook}
info={info}
usage={usage}
version="1.2.0"
>

<Demo />
Expand Down
2 changes: 1 addition & 1 deletion example/src/hooks/useGeolocation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export default function GeoLocationComponent() {
hook={hook}
info={info}
usage={usage}
version="1.5.0"
>
<Demo />

</Documentation>

</Suspense>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useGroupByFirstLetter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function GroupByFirstLetterComponent() {
hook={hook}
info={info}
usage={usage}
version="1.6.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useHash/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function HashComponent() {
hook={hook}
info={info}
usage={usage}
version="1.10.1"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useIsAppOffline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function IsAppOfflineComponent() {
hook={hook}
info={info}
usage={usage}
version="1.2.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/usePrevious/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function PreviousComponent() {
hook={hook}
info={info}
usage={usage}
version="1.0.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useProvidersTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function ProvidersTreeComponent() {
hook={hook}
info={info}
usage={usage}
version="1.11.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useScript/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function ScriptComponent() {
hook={hook}
info={info}
usage={usage}
version="1.2.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useScrollToTop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function ScrollToTopComponent() {
hook={hook}
info={info}
usage={usage}
version="1.7.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useSpeech/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function SpeechComponent() {
hook={hook}
info={info}
usage={usage}
version="1.10.1"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useStateJson/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function StateJsonComponent() {
hook={hook}
info={info}
usage={usage}
version="1.5.5"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useStateWithHistory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function StateWithHistoryComponent() {
hook={hook}
info={info}
usage={usage}
version="1.0.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useStorage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function StorageComponent() {
hook={`${sessionStorageHook}, ${localStorageHook}`}
info={info}
usage={usage}
version="1.0.7"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useSubdomain/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function SubdomainComponent() {
hook={hook}
info={info}
usage={usage}
version="1.5.3"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useTimeout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function TimeoutComponent({ defaultTimeout }: any) {
hook={hook}
info={info}
usage={usage}
version="1.0.0"
>
<Demo defaultTimeout={defaultTimeout} />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useToggle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function ToggleComponent() {
hook={hook}
info={info}
usage={usage}
version="1.0.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useUpdateEffect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function UpdateEffectComponent() {
hook={hook}
info={info}
usage={usage}
version="1.0.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useWindowDimensions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function WindowDimensionsComponent() {
hook={hook}
info={info}
usage={usage}
version="1.3.0"
>
<Demo />
</Documentation>
Expand Down
1 change: 1 addition & 0 deletions example/src/hooks/useWindowFocus/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function WindowFocusComponent() {
hook={hook}
info={info}
usage={usage}
version="1.5.0"
>
<Demo />
</Documentation>
Expand Down
3 changes: 3 additions & 0 deletions src/useArray/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useState } from 'react';

/**
* @since 1.0.0
*/
export default function useArray<T>(defaultValue: T[]) {
const [array, setArray] = useState(defaultValue);

Expand Down
3 changes: 3 additions & 0 deletions src/useAsync/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useEffect, useCallback, useState } from 'react';

/**
* @since 1.1.0
*/
export default function useAsync(callback: Function, dependencies: any = []) {
const [loading, setLoading] = useState(true);
const [error, setError] = useState();
Expand Down
3 changes: 3 additions & 0 deletions src/useAsyncLoop/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @since 1.5.0
*/
export default function useAsyncLoop() {
const executeLoop = async (data: any[], func: Function) => {
await Promise.all(
Expand Down
3 changes: 3 additions & 0 deletions src/useClickOutside/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { useEffect, useRef } from 'react';

const DEFAULT_EVENTS = ['mouseup', 'touchend'];

/**
* @since 1.12.0
*/
export default function useClickOutside(
callback: Function,
events?: string[] | null | undefined
Expand Down
5 changes: 2 additions & 3 deletions src/useColorBlend/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
* rgbA, rebB - Array of integer or string values
* Values must be between 0 to 255
/**
* @since 1.6.0
*/
export default function useColorBlend(rgbA: number[], rgbB: number[]) {
const colorChannelMixer = (colorA: number, colorB: number) => {
Expand Down
3 changes: 3 additions & 0 deletions src/useColorScheme/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useEffect, useState } from 'react';

/**
* @since 1.12.0
*/
export default function useColorScheme() {
const isDarkMode =
window.matchMedia &&
Expand Down
3 changes: 3 additions & 0 deletions src/useCopyToClipboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* eslint-disable */
/**
* @since 1.5.0
*/
export default function useCopyToClipboard() {
const copyToClipboard = async (textToCopy: string) => {
return new Promise(async (resolve, reject) => {
Expand Down
3 changes: 3 additions & 0 deletions src/useDebounce/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useEffect } from 'react';
import useTimeout from '../useTimeout';

/**
* @since 1.5.0
*/
export default function useDebounce(
callback: Function,
delay: number,
Expand Down
3 changes: 3 additions & 0 deletions src/useEventListener/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useEffect, useRef } from 'react';

/**
* @since 1.2.0
*/
export default function useEventListener(
eventType: any,
callback: Function,
Expand Down
3 changes: 3 additions & 0 deletions src/useFetch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const DEFAULT_OPTIONS = {
headers: { 'Content-Type': 'application/json' },
};

/**
* @since 1.2.0
*/
export default function useFetch(
url: string,
options = {},
Expand Down
3 changes: 3 additions & 0 deletions src/useGeolocation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useEffect, useState } from 'react';

/**
* @since 1.5.0
*/
export default function useGeolocation(options: PositionOptions = {}) {
const [loading, setLoading] = useState(true);
const [error, setError] = useState<any>();
Expand Down
3 changes: 3 additions & 0 deletions src/useGroupByFirstLetter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @since 1.6.0
*/
export default function useGroupByFirstLetter() {
const groupByFirstLetter = (data: any[], propertyName: any) => {
const groupByData = data.reduce((r, e) => {
Expand Down
Loading

0 comments on commit 7f848c6

Please sign in to comment.