Giter Club home page Giter Club logo

kadvice's Introduction

Kadvice

⚡️ Fixtures

한국어 기반 명언 모음집입니다. 영어의 고통에서 해방되세요.

  • 💡 한국어 기반 명언 모음집
  • 🛠️ 필요에 따라 명언 모음을 변경할 수 있는 커스터마이징 기능
  • 🔩 7KB의 작은 용량 (Gzip 기준)
  • 🔑 TypeScript 완벽 지원
  • 📦 삶과 동기부여 등에 대한 100여개의 명연

🌐 Demo

데모 보러가기 명언 리스트 보기

📦 Install

npm i kadvice

// or

yarn add kadvice

⌨️ Type

타입명 타입 설명
author string 말한 사람의 이름
authorProfile string 말한 사람의 직업 or 별칭
message string 말한 내용
tag 1, 2, 3 주제에 따른 태그 번호.1 = 삶 관련, 2 = 동기부여 관련, 3 = 기타

🔨 Usage

import { kadvice } from 'kadvice';

const advices = kadvice.getAll();
const advice = kadvice.getOne();
const dailyAdvice = kadvice.getOneByDaily();

🗃️ API

1. getAll()

  • getAll() 함수는 전체 명언 리스트를 반환합니다. (배열을 반환)
  • getAll 함수는 1 | 2 | 3을 인자로 받아 특정 태그의 전체 명언 리스트를 반환합니다.

Example

const advices = kadvice.getAll();

// or

const lifeAdvices = kadvice.getAll(1);

2. getOne()

  • getOne() 함수는 명언 리스트 중 하나를 랜덤으로 반환 합니다. (객체를 반환)
  • getOne 함수는 1 | 2 | 3을 인자로 받아 특정 태그의 명언 리스트 중 하나를 랜덤으로 반환합니다.

Example

const advice = kadvice.getOne();

// or

const lifeAdvice = kadvice.getOne(1);

3. getOneByDaily()

  • daily() 함수는 매일 자정에 새로운 명언을 반환합니다.
  • daily 함수는 1 | 2 | 3을 인자로 받아 특정 태그의 명언을 반환합니다.
  • 내부적으로 로컬스토리지를 활용하며, countmidNight을 key로 사용합니다.

Example

const daily = kadvice.getOneByDaily();

or;

const daily = kadvice.getOneByDaily(1);

리액트에선 다음과 같이 활용하세요.

const [dailyAdvice, setDailyAdvice] = kadvice.getOne();

const handleClick = () => {
  setDailyAdvice(kadvice.getOne());
};

Customizing

  • 커스터마이징 기능을 지원합니다.
import { KadviceService, KadviceStorageService } from "kadvice";

const sampleJson: KadviceJsonModel[] = [
  {
    author: 'Alice',
    authorProfile: 'Designer',
    message: 'This is message number 1.',
    tag: 1,
  },
  {
    author: 'Bob',
    authorProfile: 'Doctor',
    message: 'This is message number 2.',
    tag: 2,
  },
  // ...etc
];

function getCustomAdvice() {
  return new KadviceService(sampleJson, new KadviceStorageService()));
}

const kadvice = getCustomAdvice();
  • 원하는 명언을 추가할 수 있습니다.
import { KadviceService, KadviceStorageService, getAdviceFixtures } from "kadvice";

const sampleJson: KadviceJsonModel[] = [
  ...getAdviceFixtures(),
  {
    author: 'Alice',
    authorProfile: 'Designer',
    message: 'This is message number 1.',
    tag: 1,
  },
  {
    author: 'Bob',
    authorProfile: 'Doctor',
    message: 'This is message number 2.',
    tag: 2,
  },
  // ...etc
];

function getCustomAdvice() {
  return new KadviceService(sampleJson, new KadviceStorageService()));
}

const kadvice = getCustomAdvice();
  • 원하는 localStorage key로 변경할 수 있습니다.
function getCustomAdvice() {
  return new KadviceService(sampleJson, new KadviceStorageService('customCountKey', 'customMidNightKey')));
}

const kadvice = getCustomAdvice();

kadvice's People

Contributors

chkim116 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

kadvice's Issues

타입 이슈

  • TypeScript 버전: 4.9.3
  • 패키지 버전: 2.0.1
  • 설치 시 사용한 명령어: pnpm add kadvice

안녕하세요. kadvice 모듈 임포트 시 타입스크립트가 해당 모듈을 인식하지 못하는 문제가 나타나고 있습니다.

모듈 임포트 오류
index.d.ts 파일에서 발생하는 오류
node_modules 폴더 구조

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.