Skip to content

Commit

Permalink
Merge pull request #4 from naorye/fix-missing-key-and-ts-issues
Browse files Browse the repository at this point in the history
Several fixes / features
  • Loading branch information
m-Nightly committed Apr 20, 2020
2 parents 3d8f9a0 + 401fa72 commit 7132d1a
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 57 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"private": false,
"repository": "nightborn-be/signum",
"main": "dist/index.js",
"types": "./dist/index.d.ts",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"files": [
Expand Down Expand Up @@ -44,9 +45,6 @@
"@types/react": "^16.7.22",
"cross-env": "^5.2.0",
"gh-pages": "^2.0.1",
"react": "^16.9.0",
"react-scripts": "^3.4.0",
"react-test-renderer": "^16.9.0",
"typescript": "^3.2.4"
}
}
}
8 changes: 8 additions & 0 deletions src/common.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare module "*.svg" {
import React = require("react");
export const ReactComponent: React.FunctionComponent<React.SVGProps<
SVGSVGElement
>>;
const src: string;
export default src;
}
8 changes: 4 additions & 4 deletions src/components/chat-body/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import './style.scss';
import React, { useState, useEffect } from 'react';
import { IOption } from '../../interfaces/IOption';
import { motion, useAnimation } from 'framer-motion';
import { useChat } from '../chat-context/ChatContext';
import { IOption } from '../../types';

export default function ChatBody() {

Expand Down Expand Up @@ -144,7 +144,7 @@ export default function ChatBody() {
</div>
<div onClick={closeChat} className="chat-body-header-title-close-button">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.04261 2.45673L5.58588 7L1.04261 11.5433C0.652462 11.9334 0.652463 12.5672 1.04261 12.9574C1.43276 13.3475 2.06658 13.3475 2.45673 12.9574L7 8.41412L11.5433 12.9574C11.9334 13.3475 12.5672 13.3475 12.9574 12.9574C13.3475 12.5672 13.3475 11.9334 12.9574 11.5433L8.41412 7L12.9574 2.45673C13.3475 2.06658 13.3475 1.43276 12.9574 1.04261C12.5672 0.652463 11.9334 0.652462 11.5433 1.04261L7 5.58588L2.45673 1.04261C2.06658 0.652463 1.43276 0.652463 1.04261 1.04261C0.652463 1.43276 0.652463 2.06658 1.04261 2.45673Z" fill="white" stroke="white" stroke-width="0.5" />
<path d="M1.04261 2.45673L5.58588 7L1.04261 11.5433C0.652462 11.9334 0.652463 12.5672 1.04261 12.9574C1.43276 13.3475 2.06658 13.3475 2.45673 12.9574L7 8.41412L11.5433 12.9574C11.9334 13.3475 12.5672 13.3475 12.9574 12.9574C13.3475 12.5672 13.3475 11.9334 12.9574 11.5433L8.41412 7L12.9574 2.45673C13.3475 2.06658 13.3475 1.43276 12.9574 1.04261C12.5672 0.652463 11.9334 0.652462 11.5433 1.04261L7 5.58588L2.45673 1.04261C2.06658 0.652463 1.43276 0.652463 1.04261 1.04261C0.652463 1.43276 0.652463 2.06658 1.04261 2.45673Z" fill="white" stroke="white" strokeWidth="0.5" />
</svg>
</div>
</div>
Expand All @@ -168,7 +168,7 @@ export default function ChatBody() {
</div>
<div onClick={reset} className="chat-body-header-title-close-button">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.04261 2.45673L5.58588 7L1.04261 11.5433C0.652462 11.9334 0.652463 12.5672 1.04261 12.9574C1.43276 13.3475 2.06658 13.3475 2.45673 12.9574L7 8.41412L11.5433 12.9574C11.9334 13.3475 12.5672 13.3475 12.9574 12.9574C13.3475 12.5672 13.3475 11.9334 12.9574 11.5433L8.41412 7L12.9574 2.45673C13.3475 2.06658 13.3475 1.43276 12.9574 1.04261C12.5672 0.652463 11.9334 0.652462 11.5433 1.04261L7 5.58588L2.45673 1.04261C2.06658 0.652463 1.43276 0.652463 1.04261 1.04261C0.652463 1.43276 0.652463 2.06658 1.04261 2.45673Z" fill="white" stroke="white" stroke-width="0.5" />
<path d="M1.04261 2.45673L5.58588 7L1.04261 11.5433C0.652462 11.9334 0.652463 12.5672 1.04261 12.9574C1.43276 13.3475 2.06658 13.3475 2.45673 12.9574L7 8.41412L11.5433 12.9574C11.9334 13.3475 12.5672 13.3475 12.9574 12.9574C13.3475 12.5672 13.3475 11.9334 12.9574 11.5433L8.41412 7L12.9574 2.45673C13.3475 2.06658 13.3475 1.43276 12.9574 1.04261C12.5672 0.652463 11.9334 0.652462 11.5433 1.04261L7 5.58588L2.45673 1.04261C2.06658 0.652463 1.43276 0.652463 1.04261 1.04261C0.652463 1.43276 0.652463 2.06658 1.04261 2.45673Z" fill="white" stroke="white" strokeWidth="0.5" />
</svg>
</div>
</div>
Expand All @@ -186,7 +186,7 @@ export default function ChatBody() {

<div className="chat-body-content-options">
{option.options && option.options.map((option) => (
<motion.div whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.9 }} onClick={() => handleOptionClicked(option)} className="chat-body-content-option" style={{ background: config.mainColor }}>
<motion.div key={option.name} whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.9 }} onClick={() => handleOptionClicked(option)} className="chat-body-content-option" style={{ background: config.mainColor }}>
{option.name}
</motion.div>
))}
Expand Down
8 changes: 0 additions & 8 deletions src/components/chat-body/interfaces/IChatBodyInformation.ts

This file was deleted.

10 changes: 9 additions & 1 deletion src/components/chat-context/ChatContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { createContext, useContext } from "react";
import { IChatContext } from "./interfaces/IChatContext";
import { defaultConfig, defaultOption } from "../../constants";
import { IChatConfig, IOption } from "../../types";

interface IChatContext {
isOpen: boolean,
config: IChatConfig,
openChat: () => void,
closeChat: () => void,
defaultOption: IOption
}

const ChatContext = createContext<IChatContext>({
isOpen: false,
Expand Down
8 changes: 7 additions & 1 deletion src/components/chat-context/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import React, { useState } from "react";
import { ChatContext } from "./ChatContext";
import { IChatProviderProps } from "./interfaces/IChatProviderProps";
import { defaultConfig, defaultOption } from "../../constants";
import { IOption, IChatConfig } from '../../types';

export interface IChatProviderProps {
option: IOption,
config: IChatConfig,
children: any
}

export default function ChatContextProvider(props: IChatProviderProps) {

Expand Down
10 changes: 0 additions & 10 deletions src/components/chat-context/interfaces/IChatContext.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/components/chat-context/interfaces/IChatProviderProps.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IOption } from "../interfaces/IOption"
import { IChatConfig } from "../interfaces/IChatConfig"
import { IChatConfig, IOption } from "../types"

export const defaultConfig: IChatConfig = {
openByDefault: false,
Expand Down
9 changes: 8 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import React from 'react';
import ChatBody from './components/chat-body';
import ChatIcon from './components/chat-icon';
import { IChatProps } from './interfaces/IChatProps';
import ChatContextProvider from './components/chat-context';
import { IOption, IChatConfig } from './types';

interface IChatProps {
option: IOption,
config: IChatConfig
}

export * from './types';

export default function Chat(props: IChatProps) {
return (
Expand Down
7 changes: 0 additions & 7 deletions src/interfaces/IChatProps.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/interfaces/IOption.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/react-app-env.d.ts

This file was deleted.

20 changes: 18 additions & 2 deletions src/interfaces/IChatConfig.ts → src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
import { IChatBodyInformation } from "../components/chat-body/interfaces/IChatBodyInformation";
import { ReactNode } from "react";

export interface IOption {
title: string,
subTitle?: string,
message: ReactNode,
name: string,
handleOnClick?: Function,
options?: IOption[]
}

export interface IChatBodyInformation {
email: string,
message: string,
steps: IOption[],
option: IOption
}

export interface IChatConfig {
openByDefault: boolean,
Expand All @@ -15,4 +31,4 @@ export interface IChatConfig {
sendButtonColor: string,
handleFinalButtonClicked?: () => void,
handleSendClicked: (information: IChatBodyInformation) => void
}
}

0 comments on commit 7132d1a

Please sign in to comment.