Skip to content

Commit

Permalink
feat: handle create article
Browse files Browse the repository at this point in the history
  • Loading branch information
hthieu1110 committed Aug 5, 2023
2 parents 6b9e8d3 + 0f02a94 commit f28b896
Show file tree
Hide file tree
Showing 30 changed files with 542 additions and 226 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
"@typescript-eslint/no-unused-vars": "error",
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
"react-hooks/exhaustive-deps": "error", // Checks effect dependencies
"prettier/prettier": "error",
},
overrides: [
{
Expand Down
3 changes: 3 additions & 0 deletions assets/icons/lock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/candymachine/pinata-upload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";

import { LocalFileData } from "../utils/types/feed";
import { LocalFileData } from "../utils/types/files";

interface PinataFileProps {
file: LocalFileData;
Expand Down
4 changes: 2 additions & 2 deletions packages/components/FilePreview/AudioView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { View, Image, TouchableOpacity } from "react-native";
import { ActivityIndicator } from "react-native-paper";

import { AudioWaveform } from "./AudioWaveform";
import { ipfsURLToHTTPURL } from "./ipfs";
import pauseSVG from "../../../assets/icons/pause.svg";
import playSVG from "../../../assets/icons/play.svg";
import { useMaxResolution } from "../../hooks/useMaxResolution";
import { getAudioDuration } from "../../utils/audio";
import { ipfsURLToHTTPURL } from "../../utils/ipfs";
import {
errorColor,
neutral00,
Expand All @@ -17,7 +17,7 @@ import {
} from "../../utils/style/colors";
import { fontSemibold13, fontSemibold14 } from "../../utils/style/fonts";
import { layout, screenContentMaxWidth } from "../../utils/style/layout";
import { RemoteFileData } from "../../utils/types/feed";
import { RemoteFileData } from "../../utils/types/files";
import { BrandText } from "../BrandText";
import { SVG } from "../SVG";
import { THUMBNAIL_WIDTH } from "../socialFeed/SocialThread/SocialMessageContent";
Expand Down
2 changes: 1 addition & 1 deletion packages/components/FilePreview/EditableAudioPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "../../utils/style/colors";
import { fontMedium32, fontSemibold12 } from "../../utils/style/fonts";
import { layout } from "../../utils/style/layout";
import { LocalFileData } from "../../utils/types/feed";
import { LocalFileData } from "../../utils/types/files";
import { BrandText } from "../BrandText";
import { SVG } from "../SVG";
import { FileUploader } from "../fileUploader";
Expand Down
2 changes: 1 addition & 1 deletion packages/components/FilePreview/FilesPreviewsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { VideoView } from "./VideoView";
import { GIF_MIME_TYPE } from "../../utils/mime";
import { convertGIFToLocalFileType } from "../../utils/social-feed";
import { layout } from "../../utils/style/layout";
import { LocalFileData, RemoteFileData } from "../../utils/types/feed";
import { LocalFileData, RemoteFileData } from "../../utils/types/files";

interface FilePreviewContainerProps {
files?: LocalFileData[];
Expand Down
2 changes: 1 addition & 1 deletion packages/components/FilePreview/ImagesFullViewModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
} from "react-native";
import { SvgProps } from "react-native-svg";

import { ipfsURLToHTTPURL } from "./ipfs";
import chevronLeft from "../../../assets/icons/chevron-left.svg";
import chevronRight from "../../../assets/icons/chevron-right.svg";
import { ipfsURLToHTTPURL } from "../../utils/ipfs";
import { neutral22, neutral33 } from "../../utils/style/colors";
import { SVG } from "../SVG";
import ModalBase from "../modals/ModalBase";
Expand Down
4 changes: 2 additions & 2 deletions packages/components/FilePreview/ImagesViews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Image, TouchableOpacity, View } from "react-native";

import { DeleteButton } from "./DeleteButton";
import { ImagesFullViewModal } from "./ImagesFullViewModal";
import { ipfsURLToHTTPURL } from "./ipfs";
import { ipfsURLToHTTPURL } from "../../utils/ipfs";
import { errorColor } from "../../utils/style/colors";
import { fontSemibold13 } from "../../utils/style/fonts";
import { layout } from "../../utils/style/layout";
import { LocalFileData, RemoteFileData } from "../../utils/types/feed";
import { LocalFileData, RemoteFileData } from "../../utils/types/files";
import { BrandText } from "../BrandText";

interface ImagePreviewProps {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/FilePreview/VideoView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import React from "react";
import { View } from "react-native";

import { DeleteButton } from "./DeleteButton";
import { ipfsURLToHTTPURL } from "./ipfs";
import { ipfsURLToHTTPURL } from "../../utils/ipfs";
import { errorColor } from "../../utils/style/colors";
import { fontSemibold13 } from "../../utils/style/fonts";
import { layout } from "../../utils/style/layout";
import { LocalFileData, RemoteFileData } from "../../utils/types/feed";
import { LocalFileData, RemoteFileData } from "../../utils/types/files";
import { BrandText } from "../BrandText";

interface VideoPreviewProps {
Expand Down
15 changes: 0 additions & 15 deletions packages/components/FilePreview/ipfs.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/components/fileUploader/FileUploader.type.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { StyleProp, ViewStyle } from "react-native";

import { LocalFileData } from "../../utils/types/feed";
import { LocalFileData } from "../../utils/types/files";

export interface FileUploaderProps {
onUpload: (files: LocalFileData[]) => void;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/fileUploader/formatFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
IMAGE_MIME_TYPES,
VIDEO_MIME_TYPES,
} from "./../../utils/mime";
import { FileType, LocalFileData } from "../../utils/types/feed";
import { FileType, LocalFileData } from "../../utils/types/files";
import { getAudioData } from "../../utils/waveform";

export const formatFile = async (file: File): Promise<LocalFileData> => {
Expand Down
232 changes: 232 additions & 0 deletions packages/components/inputs/SelectInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
import React, { ReactElement, useState } from "react";
import {
View,
ScrollView,
StyleSheet,
StyleProp,
ViewStyle,
} from "react-native";

import { Label } from "./TextInputCustom";
import chevronDownSVG from "../../../assets/icons/chevron-down.svg";
import chevronUpSVG from "../../../assets/icons/chevron-up.svg";
import lockSVG from "../../../assets/icons/lock.svg";
import {
neutral00,
neutral33,
neutral77,
neutralA3,
secondaryColor,
} from "../../utils/style/colors";
import { fontMedium13, fontSemibold14 } from "../../utils/style/fonts";
import { layout } from "../../utils/style/layout";
import { BrandText } from "../BrandText";
import { SVG } from "../SVG";
import { CustomPressable } from "../buttons/CustomPressable";
import { SpacerColumn, SpacerRow } from "../spacer";

export type SelectInputDataValue = string | number;

export type SelectInputData = {
label: string;
value: SelectInputDataValue;
iconComponent?: ReactElement;
};

type Props = {
data: SelectInputData[];
placeHolder?: string;
selectedData: SelectInputData;
setData: (data: SelectInputData) => void;
disabled?: boolean;
style?: StyleProp<ViewStyle>;
boxStyle?: StyleProp<ViewStyle>;
label?: string;
isRequired?: boolean;
};

export const SelectInput: React.FC<Props> = ({
data,
placeHolder,
selectedData,
setData,
disabled,
style,
boxStyle,
label,
isRequired,
}) => {
const [openMenu, setOpenMenu] = useState<boolean>(false);
const [hoveredIndex, setHoveredIndex] = useState<number>(0);
const [hovered, setHovered] = useState(false);

const getScrollViewStyle = () => {
if (data.length > 5) {
return [styles.dropdownMenu, { height: 200 }];
}
return styles.dropdownMenu;
};

return (
<CustomPressable
style={[style, { position: "relative", zIndex: 999 }]}
onHoverIn={() => setHovered(true)}
onHoverOut={() => setHovered(false)}
onPress={() => {
if (!disabled || data.length) setOpenMenu((value) => !value);
}}
disabled={disabled || !data.length}
>
{label && (
<>
<Label
hovered={hovered}
style={{ color: neutralA3 }}
isRequired={isRequired}
>
{label}
</Label>
<SpacerColumn size={1.5} />
</>
)}
<View>
<View
style={[
styles.selectInput,
hovered && { borderColor: secondaryColor },
boxStyle,
]}
>
<View style={styles.iconLabel}>
{selectedData.iconComponent && (
<>
{selectedData.iconComponent}
<SpacerRow size={1} />
</>
)}

<BrandText
style={[
fontSemibold14,
{ color: selectedData ? secondaryColor : neutral77 },
]}
>
{selectedData?.label ? selectedData.label : placeHolder}
</BrandText>
</View>

<SVG
source={
!data.length || disabled
? lockSVG
: openMenu
? chevronUpSVG
: chevronDownSVG
}
width={16}
height={16}
color={secondaryColor}
/>
</View>

{/*TODO: If the opened menu appears under other elements, you'll may need to set zIndex:-1 or something to these elements*/}
{openMenu && (
<ScrollView style={getScrollViewStyle()}>
{data.map((item, index) => (
<CustomPressable
onHoverIn={() => {
setHoveredIndex(index + 1);
setHovered(true);
}}
onHoverOut={() => {
setHoveredIndex(0);
setHovered(false);
}}
onPress={() => {
setData(item);
setOpenMenu(false);
}}
key={index}
style={styles.dropdownMenuRow}
>
<View
style={[
styles.iconLabel,
hoveredIndex === index + 1 && { opacity: 0.5 },
]}
>
{item.iconComponent && (
<>
{item.iconComponent}
<SpacerRow size={1.5} />
</>
)}

<BrandText style={styles.dropdownMenuText}>
{item.label}
</BrandText>
</View>
</CustomPressable>
))}
</ScrollView>
)}
</View>
</CustomPressable>
);
};

const styles = StyleSheet.create({
selectInputLabel: StyleSheet.flatten([fontSemibold14, { color: neutralA3 }]),
selectInput: {
backgroundColor: neutral00,
fontSize: 14,
fontWeight: 600,
color: secondaryColor,
borderColor: neutral33,
borderWidth: 1,
borderRadius: 12,
padding: layout.padding_x1_5,
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
},
inputContainer: {
backgroundColor: neutral00,
borderWidth: 1,
borderColor: neutral33,
borderRadius: 12,
paddingHorizontal: layout.padding_x1_5,
},
inputItemStyle: {
backgroundColor: "#292929",
color: neutralA3,
paddingVertical: layout.padding_x1_5,
paddingHorizontal: layout.padding_x1,
},
iconLabel: {
flexDirection: "row",
alignItems: "center",
},

dropdownMenu: {
backgroundColor: "#292929",
borderWidth: 1,
borderColor: neutral33,
borderRadius: 12,
padding: layout.padding_x1,
position: "absolute",
top: 52,
width: "100%",
zIndex: 10,
},
dropdownMenuText: StyleSheet.flatten([fontMedium13]),
dropdownMenuRow: {
borderRadius: 6,
padding: layout.padding_x1,
},
// dropdownMenuRow: {
// backgroundColor: neutral00,
// borderRadius: 6,
// padding: layout.padding_x1,
// },
});
Loading

0 comments on commit f28b896

Please sign in to comment.