From de962de30c9b7692a582b643331e0b23c0cbc929 Mon Sep 17 00:00:00 2001 From: Arifulislam5577 Date: Sun, 24 Dec 2023 18:13:36 +0600 Subject: [PATCH] Removed: Removed un-wanted console log. --- .github/workflows/ci.yaml | 32 +++++++++++++++++ .github/workflows/preview.yaml | 21 ++++++++++++ .github/workflows/production.yaml | 21 ++++++++++++ app/components/ComponentsList.tsx | 4 +-- .../checkbox/variant/CheckboxVariant.tsx | 25 ++------------ .../checkbox/variant/DefaultCheckbox.tsx | 18 ++-------- .../variant/DatePickerWithTwoMonth.tsx | 5 +-- .../datePicker/variant/DateRangePicker.tsx | 6 +--- .../variant/DateRangePickerWithTwoMonth.tsx | 6 +--- .../datePicker/variant/DefaultDatePicker.tsx | 5 +-- .../datePicker/variant/MonthPicker.tsx | 5 +-- .../datePicker/variant/TimePicker.tsx | 5 +-- .../datePicker/variant/YearPicker.tsx | 5 +-- .../components/modal/variant/HistoryModal.tsx | 10 ++---- .../switch/variant/DefaultSwitch.tsx | 3 +- .../components/switch/variant/SwitchSizes.tsx | 15 ++++---- .../switch/variant/SwitchWithBackground.tsx | 5 +-- .../switch/variant/SwitchWithIcon.tsx | 3 +- .../tree/variant/TreeWithCheckbox.tsx | 5 +-- app/page.tsx | 2 +- .../DatePicker/DatePicker.stories.tsx | 23 ++++--------- app/src/components/Switch/index.tsx | 19 +++++++++-- tsconfig.json | 34 ++++++++++++------- tsconfig.lib.json | 4 +-- 24 files changed, 155 insertions(+), 126 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/preview.yaml create mode 100644 .github/workflows/production.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..aded1c96 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,32 @@ +name: Continuous Integration + +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all history for all branches and tags + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: '20.9.0' + + - name: Install dependencies + run: npm install + + - name: Run lint + run: npm run lint + + - name: Run format check + run: npm run format + + - name: Check commit messages + uses: wagoid/commitlint-github-action@v3 + with: + configFile: commitlint.config.cjs diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml new file mode 100644 index 00000000..26539ae2 --- /dev/null +++ b/.github/workflows/preview.yaml @@ -0,0 +1,21 @@ +name: GitHub Actions Vercel Preview Deployment +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} +on: + push: + branches-ignore: + - main +jobs: + Deploy-Preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install Vercel CLI + run: npm install --global vercel@canary + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/production.yaml b/.github/workflows/production.yaml new file mode 100644 index 00000000..5e5451de --- /dev/null +++ b/.github/workflows/production.yaml @@ -0,0 +1,21 @@ +name: GitHub Actions Vercel Production Deployment +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} +on: + push: + branches: + - main +jobs: + Deploy-Production: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Vercel CLI + run: npm install --global vercel@canary + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/app/components/ComponentsList.tsx b/app/components/ComponentsList.tsx index af0670b3..5f59c3d1 100644 --- a/app/components/ComponentsList.tsx +++ b/app/components/ComponentsList.tsx @@ -98,11 +98,9 @@ export const CheckboxGroupComponent = () => { ) } export const DatePickerComponent = () => { - const [date, setDate] = useState(null) - console.log(date) return (
- +
diff --git a/app/docs/components/checkbox/variant/CheckboxVariant.tsx b/app/docs/components/checkbox/variant/CheckboxVariant.tsx index 692b3950..a42064fb 100644 --- a/app/docs/components/checkbox/variant/CheckboxVariant.tsx +++ b/app/docs/components/checkbox/variant/CheckboxVariant.tsx @@ -2,29 +2,10 @@ import { CheckBox } from '../../../../src' const CheckboxVariant = () => { - const handleChecked = (value: boolean) => { - console.log(value) - } return (
- - + +
) } @@ -35,7 +16,7 @@ import { CheckBox } from "keep-react"; export const CheckboxComponent = () => { const handleChecked = (value) => { - console.log(value); + // value is available }; return ( <> diff --git a/app/docs/components/checkbox/variant/DefaultCheckbox.tsx b/app/docs/components/checkbox/variant/DefaultCheckbox.tsx index c40b0c1d..09e2a900 100644 --- a/app/docs/components/checkbox/variant/DefaultCheckbox.tsx +++ b/app/docs/components/checkbox/variant/DefaultCheckbox.tsx @@ -2,21 +2,7 @@ import { CheckBox } from '../../../../src' const DefaultCheckbox = () => { - const handleChecked = (value: boolean) => { - console.log(value) - } - return ( -
- -
- ) + return } const DefaultCheckboxCode = ` @@ -25,7 +11,7 @@ import { CheckBox } from "keep-react"; export const CheckboxComponent = () => { const handleChecked = (value) => { - console.log(value); + //value }; return ( { - const [date, setDate] = useState(null) - console.log(date) return (
- +
diff --git a/app/docs/components/datePicker/variant/DateRangePicker.tsx b/app/docs/components/datePicker/variant/DateRangePicker.tsx index 5e82e7a2..3987a036 100644 --- a/app/docs/components/datePicker/variant/DateRangePicker.tsx +++ b/app/docs/components/datePicker/variant/DateRangePicker.tsx @@ -1,14 +1,10 @@ 'use client' -import { useState } from 'react' import { DatePicker } from '../../../../src' -import { rangePicker } from '../../../../src/components/DatePicker/DatePickerContext' const DateRangePicker = () => { - const [range, setRangeDate] = useState() - console.log(range) return (
- +
diff --git a/app/docs/components/datePicker/variant/DateRangePickerWithTwoMonth.tsx b/app/docs/components/datePicker/variant/DateRangePickerWithTwoMonth.tsx index 6ec12a8f..724e9a99 100644 --- a/app/docs/components/datePicker/variant/DateRangePickerWithTwoMonth.tsx +++ b/app/docs/components/datePicker/variant/DateRangePickerWithTwoMonth.tsx @@ -1,14 +1,10 @@ 'use client' -import { useState } from 'react' import { DatePicker } from '../../../../src' -import { rangePicker } from '../../../../src/components/DatePicker/DatePickerContext' const DateRangePickerWithTwoMonth = () => { - const [date, setRangeDate] = useState() - console.log(date) return (
- +
diff --git a/app/docs/components/datePicker/variant/DefaultDatePicker.tsx b/app/docs/components/datePicker/variant/DefaultDatePicker.tsx index c20a49a1..ca347bd9 100644 --- a/app/docs/components/datePicker/variant/DefaultDatePicker.tsx +++ b/app/docs/components/datePicker/variant/DefaultDatePicker.tsx @@ -1,13 +1,10 @@ 'use client' -import { useState } from 'react' import { DatePicker } from '../../../../src' const DefaultDatePicker = () => { - const [date, setDate] = useState(null) - console.log(date) return (
- +
diff --git a/app/docs/components/datePicker/variant/MonthPicker.tsx b/app/docs/components/datePicker/variant/MonthPicker.tsx index eb7a935d..0775baf1 100644 --- a/app/docs/components/datePicker/variant/MonthPicker.tsx +++ b/app/docs/components/datePicker/variant/MonthPicker.tsx @@ -1,13 +1,10 @@ 'use client' -import { useState } from 'react' import { DatePicker } from '../../../../src' const MonthPicker = () => { - const [month, setMonthPicker] = useState() - console.log(month) return (
- +
diff --git a/app/docs/components/datePicker/variant/TimePicker.tsx b/app/docs/components/datePicker/variant/TimePicker.tsx index 0514ee88..e2fbb575 100644 --- a/app/docs/components/datePicker/variant/TimePicker.tsx +++ b/app/docs/components/datePicker/variant/TimePicker.tsx @@ -1,13 +1,10 @@ 'use client' -import { useState } from 'react' import { DatePicker } from '../../../../src' const TimePicker = () => { - const [time, setTime] = useState() - console.log(time) return (
- +
diff --git a/app/docs/components/datePicker/variant/YearPicker.tsx b/app/docs/components/datePicker/variant/YearPicker.tsx index 5024bef1..747dc9bb 100644 --- a/app/docs/components/datePicker/variant/YearPicker.tsx +++ b/app/docs/components/datePicker/variant/YearPicker.tsx @@ -1,13 +1,10 @@ 'use client' -import { useState } from 'react' import { DatePicker } from '../../../../src' const YearPicker = () => { - const [year, setYearPicker] = useState() - console.log(year) return (
- +
diff --git a/app/docs/components/modal/variant/HistoryModal.tsx b/app/docs/components/modal/variant/HistoryModal.tsx index a6714d95..af757344 100644 --- a/app/docs/components/modal/variant/HistoryModal.tsx +++ b/app/docs/components/modal/variant/HistoryModal.tsx @@ -14,10 +14,6 @@ const HistoryModal = () => { setShowAccessModal(!showAccessModal) } - const handleChecked = (value: any) => { - console.log(value) - } - return (
- + @@ -66,7 +62,7 @@ const HistoryModal = () => {
- + @@ -103,7 +99,7 @@ export const ModalComponent = () => { }; const handleChecked = (value) => { - console.log(value) + //value }; return ( diff --git a/app/docs/components/switch/variant/DefaultSwitch.tsx b/app/docs/components/switch/variant/DefaultSwitch.tsx index 1303c241..c16c9f7f 100644 --- a/app/docs/components/switch/variant/DefaultSwitch.tsx +++ b/app/docs/components/switch/variant/DefaultSwitch.tsx @@ -10,7 +10,8 @@ const DefaultSwitchCode = ` import { Toggle } from "keep-react"; export const SwitchComponent = () => { - return ; + const [toggle, setToggle] = useState(false) + return return } ` diff --git a/app/docs/components/switch/variant/SwitchSizes.tsx b/app/docs/components/switch/variant/SwitchSizes.tsx index 35a802d7..c8ec9ed4 100644 --- a/app/docs/components/switch/variant/SwitchSizes.tsx +++ b/app/docs/components/switch/variant/SwitchSizes.tsx @@ -12,18 +12,19 @@ const SwitchSizes = () => { } const SwitchSizesCode = ` -"use client"; -import { useState } from "react"; -import { Toggle } from "keep-react"; +"use client" +import { useState } from "react" +import { Toggle } from "keep-react" export const SwitchComponent = () => { + const [toggle, setToggle] = useState(false) return (
- - - + + +
- ); + ) } ` diff --git a/app/docs/components/switch/variant/SwitchWithBackground.tsx b/app/docs/components/switch/variant/SwitchWithBackground.tsx index de96ec94..71118c13 100644 --- a/app/docs/components/switch/variant/SwitchWithBackground.tsx +++ b/app/docs/components/switch/variant/SwitchWithBackground.tsx @@ -14,10 +14,11 @@ const SwitchWithBackgroundCode = ` import { Toggle } from "keep-react"; export const SwitchComponent = () => { + const [toggle, setToggle] = useState(false) return (
- - + +
); } diff --git a/app/docs/components/switch/variant/SwitchWithIcon.tsx b/app/docs/components/switch/variant/SwitchWithIcon.tsx index 6a5ee9bd..30e05fd3 100644 --- a/app/docs/components/switch/variant/SwitchWithIcon.tsx +++ b/app/docs/components/switch/variant/SwitchWithIcon.tsx @@ -10,7 +10,8 @@ const SwitchWithIconCode = ` import { Toggle } from "keep-react"; export const SwitchComponent = () => { - return ; + const [toggle, setToggle] = useState(false) + return } ` export { SwitchWithIcon, SwitchWithIconCode } diff --git a/app/docs/components/tree/variant/TreeWithCheckbox.tsx b/app/docs/components/tree/variant/TreeWithCheckbox.tsx index c6e8fb07..4343b262 100644 --- a/app/docs/components/tree/variant/TreeWithCheckbox.tsx +++ b/app/docs/components/tree/variant/TreeWithCheckbox.tsx @@ -3,12 +3,9 @@ import { Tree } from '../../../../src' import { nodes } from './DefaultTree' const TreeWithCheckbox = () => { - const handleChecked = (value: boolean) => { - console.log(value) - } return (
- +
) } diff --git a/app/page.tsx b/app/page.tsx index 96ab8b00..60a6a6e0 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -115,7 +115,7 @@ const Community = () => { const result = await response.json() setContributors(result) } catch (error) { - console.log(error) + console.error(error) } } getUser() diff --git a/app/src/components/DatePicker/DatePicker.stories.tsx b/app/src/components/DatePicker/DatePicker.stories.tsx index 3eb38601..fbdd8a2a 100644 --- a/app/src/components/DatePicker/DatePicker.stories.tsx +++ b/app/src/components/DatePicker/DatePicker.stories.tsx @@ -57,9 +57,7 @@ export default meta type Story = StoryObj const DefaultDatePickerComponent = () => { - const [date, setDate] = useState(null) - console.log(date) - + const [, setDate] = useState(null) return (
@@ -69,8 +67,7 @@ const DefaultDatePickerComponent = () => { ) } const DatePickerWithTwoMonthComponent = () => { - const [date, setDate] = useState(null) - console.log(date) + const [, setDate] = useState(null) return (
@@ -80,8 +77,7 @@ const DatePickerWithTwoMonthComponent = () => { ) } const DateRangePickerComponent = () => { - const [range, setRangeDate] = useState() - console.log(range) + const [, setRangeDate] = useState() return (
@@ -91,8 +87,7 @@ const DateRangePickerComponent = () => { ) } const DateRangePickerWithTwoMonthComponent = () => { - const [range, setRangeDate] = useState() - console.log(range) + const [, setRangeDate] = useState() return (
@@ -102,8 +97,7 @@ const DateRangePickerWithTwoMonthComponent = () => { ) } const MonthPickerComponent = () => { - const [month, setMonthPicker] = useState() - console.log(month) + const [, setMonthPicker] = useState() return (
@@ -113,9 +107,7 @@ const MonthPickerComponent = () => { ) } const YearPickerComponent = () => { - const [year, setYearPicker] = useState() - console.log(year) - + const [, setYearPicker] = useState() return (
@@ -125,8 +117,7 @@ const YearPickerComponent = () => { ) } const TimePickerComponent = () => { - const [time, setTime] = useState() - console.log(time) + const [, setTime] = useState() return (
diff --git a/app/src/components/Switch/index.tsx b/app/src/components/Switch/index.tsx index 31e44711..923933f3 100644 --- a/app/src/components/Switch/index.tsx +++ b/app/src/components/Switch/index.tsx @@ -1,5 +1,5 @@ -import type { FC, ReactNode } from 'react' -import { useState } from 'react' +import type { Dispatch, FC, ReactNode, SetStateAction } from 'react' +import { useEffect, useState } from 'react' import { Switch } from '@headlessui/react' import { KeepSizes } from '../../Keep/KeepTheme' import { useTheme } from '../../Keep/ThemeContext' @@ -86,6 +86,12 @@ export interface ToggleProps { * @default '' */ labelStyle?: string + + /** + * Toggle onChange event handler + * @type {function} + */ + onChange?: Dispatch> } export interface ToggleSizes extends Pick { @@ -101,12 +107,21 @@ const ToggleComponent: FC = ({ className, circleStyle, labelStyle, + onChange, ...props }) => { const [enabled, setEnabled] = useState(false) const theirProps = excludeClassName(props) const theme = useTheme().theme.switch + useEffect(() => { + if (enabled && onChange) { + onChange(true) + } else { + onChange && onChange(false) + } + }, [enabled, onChange]) + const showWithIcon = (enabled: boolean, size: keyof ToggleSizes): string => { if (enabled) { const enableIcon: ToggleSizes = { diff --git a/tsconfig.json b/tsconfig.json index b3222239..e4b4f1c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,23 +1,33 @@ { "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": false, - "noEmit": true, - "incremental": true, + "baseUrl": ".", "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, + "forceConsistentCasingInFileNames": true, + "incremental": true, "isolatedModules": true, "jsx": "preserve", + "lib": ["DOM", "DOM.Iterable", "ESNext"], + "module": "ESNext", + "moduleResolution": "node", + "noEmit": false, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "paths": { + "~/*": ["./*"] + }, "plugins": [ { "name": "next" } - ] + ], + "resolveJsonModule": true, + "skipLibCheck": true, + "strict": true, + "target": "ESNext", + "allowJs": true }, - "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules"] + "exclude": ["./build/", "./lib/", "./.next/"], + "include": [".next/types/**/*.ts", "**/*.mdx", "**/*.ts", "**/*.tsx"] } diff --git a/tsconfig.lib.json b/tsconfig.lib.json index 89bd70ba..109bc807 100644 --- a/tsconfig.lib.json +++ b/tsconfig.lib.json @@ -5,6 +5,6 @@ "module": "CommonJS", "outDir": "./lib/cjs" }, - "exclude": ["**/*.stories.tsx"], - "include": ["./app/src/"] + "exclude": ["app/**/*.stories.tsx"], + "include": ["./app/src"] }