부품 가게·기관 정보

오시는 길 location

지도 자리와 주소(복사 단추), 지하철·버스·주차 같은 교통편 목록, 지도 앱 링크, 전화. 지도는 map(또는 children)으로 iframe·그림을 받고, 없으면 역 출구에서 걸어가는 길만 그린 약도(MapSketch)를 테마 색으로 그린다.

  • 나온 곳 온유치과
  • 오시는 길
  • 지도
  • 약도
  • 주소 복사
  • 주차
  • 교통

설치

shadcn/ui 를 쓰는 Next.js 프로젝트에서 한 줄로 설치됩니다. 파일은 components/bpublish/location.tsx 로 들어오고, 공통 토큰(base)과 함께 쓰는 부품(section-head)도 같이 설치됩니다. 테마는 테마에서 하나 고릅니다.

npx shadcn@latest add https://www.bpublish.com/r/location.json

레지스트리를 등록했다면 npx shadcn@latest add @bpublish/location · 설치 안내

AI에게 맡기기

Claude Code, Cursor 같은 AI 코딩 도구에 붙여 넣으세요. MCP 서버를 연결해 두면 이름만 말해도 됩니다.

bpublish UI의 오시는 길(location) 부품으로 만들어 줘. 설치: npx shadcn@latest add https://www.bpublish.com/r/location.json · 문서: https://www.bpublish.com/designs/components/location

사용 예시

app/page.tsx
import { Location } from '@/components/bpublish/location'

export default function Example() {
  return (
    <Location
      title="오시는 길"
      address="경기도 성남시 분당구 정자동 00길 00, 온유빌딩 3층"
      rows={[
        { label: '지하철', value: '신분당선 · 수인분당선 정자역 3번 출구에서 직진 300m, 도보 4분' },
        { label: '버스', value: '정자역 정류장 하차 후 도보 3분' },
        { label: '주차', value: '건물 지하 1~3층 주차장. 진료 당일 2시간 무료이며 접수대에서 차량 번호를 등록해 드립니다.' },
        { label: '편의', value: '건물 엘리베이터와 진료실 출입구는 휠체어로 이용하실 수 있습니다.' },
      ]}
      sketch={{ place: '온유치과', station: '정자역', exit: '3번 출구', roads: ['정자일로', '느티로'], stream: '탄천' }}
      mapLinks={[
        { label: '네이버 지도', href: 'https://map.naver.com' },
        { label: '카카오맵', href: 'https://map.kakao.com' },
      ]}
      phone={{ label: '대표 전화', number: '031-000-0000' }}
    />
  )
}

속성

이름형식기본값설명
address필수string—주소. 복사 단추가 붙는다
titlestring—구역 제목
eyebrowstring—제목 위 영문 소제목
descriptionstring—제목 옆 설명
rows{ label: string; value: string }[]—교통편·주차·편의
mapReactNode—지도 iframe·그림 (children 으로 넣어도 된다). 칸을 가득 채운다
sketch{ place: string; station?: string; exit?: string; roads?: [string, string]; stream?: string }—지도가 없을 때 그리는 약도의 이름들
mapLinks{ label: string; href: string }[]—지도 앱 링크 (새 창)
phone{ label: string; number: string }—맨 아래 전화 줄
copyLabelstring'주소 복사'복사 단추 이름
copiedLabelstring'복사했습니다'복사한 뒤 이름

원본 코드

설치 명령 없이 그대로 복사해 넣어도 됩니다. React 외의 패키지는 쓰지 않습니다.

components/bpublish/location.tsx
'use client'

/**
 * bpublish UI — 오시는 길. https://www.bpublish.com/designs/components/location
 * 지도 자리와 주소(복사 단추), 지하철·버스·주차 같은 교통편 목록, 지도 앱 링크, 전화.
 * 지도는 map(또는 children)으로 iframe·그림을 받고, 없으면 역에서 걸어가는 길만 그린 약도(MapSketch)를 그린다.
 */
import { useEffect, useRef, useState, type ReactNode } from 'react'
import { SectionHead } from './section-head'

export type MapSketchProps = {
  /** 목적지 이름 (병원·가게) */
  place: string
  /** 가까운 역 */
  station?: string
  /** 출구 ('3번 출구') */
  exit?: string
  /** 가로 큰길, 세로 길 이름 */
  roads?: [string, string]
  /** 하천·공원 이름 */
  stream?: string
  className?: string
}

export type LocationProps = {
  /** 주소. 복사 단추가 붙는다 */
  address: string
  title?: string
  eyebrow?: string
  /** 제목 옆 설명 */
  description?: string
  /** 교통편·주차·편의 (항목 이름, 내용) */
  rows?: { label: string; value: string }[]
  /** 지도 iframe·그림. 없으면 약도를 그린다 */
  map?: ReactNode
  children?: ReactNode
  /** 지도가 없을 때 약도에 쓸 이름들 */
  sketch?: MapSketchProps
  /** 지도 앱 링크 (네이버 지도, 카카오맵 …) */
  mapLinks?: { label: string; href: string }[]
  phone?: { label: string; number: string }
  addressLabel?: string
  copyLabel?: string
  copiedLabel?: string
  className?: string
}

/** 약도. 실제 지도 대신 역 출구에서 목적지까지 걷는 길만 그린 단순한 그림 */
export function MapSketch({ place, station, exit, roads, stream, className = '' }: MapSketchProps) {
  const exitNo = exit?.match(/\d+/)?.[0]
  const label = station ? `${station}${exit ? ` ${exit}` : ''}에서 ${place}까지 가는 약도` : `${place} 약도`
  return (
    <svg viewBox="0 0 720 540" role="img" aria-label={label} className={`block h-full w-full ${className}`}>
      <rect width="720" height="540" className="fill-muted" />
      {stream ? (
        <>
          <path d="M40 0 C 70 140, 20 260, 70 400 S 90 520, 80 540" fill="none" strokeWidth="46" strokeOpacity="0.12" className="stroke-primary" />
          <text x="96" y="470" fontSize="13" letterSpacing="2" className="fill-muted-foreground">
            {stream}
          </text>
        </>
      ) : null}
      {[
        [170, 40, 170, 130],
        [400, 40, 120, 130],
        [580, 40, 140, 130],
        [170, 270, 170, 110],
        [400, 270, 120, 110],
        [580, 270, 140, 110],
        [170, 440, 170, 100],
        [400, 440, 320, 100],
      ].map(([x, y, w, h], i) => (
        <rect key={i} x={x} y={y} width={w} height={h} className="fill-border" fillOpacity="0.55" />
      ))}
      <line x1="120" y1="220" x2="720" y2="220" strokeWidth="34" className="stroke-background" />
      <line x1="370" y1="0" x2="370" y2="540" strokeWidth="22" className="stroke-background" />
      <line x1="120" y1="410" x2="720" y2="410" strokeWidth="14" className="stroke-background" />
      <line x1="550" y1="0" x2="550" y2="540" strokeWidth="12" className="stroke-background" />
      {roads ? (
        <>
          <text x="590" y="225" fontSize="13" letterSpacing="1" className="fill-muted-foreground">
            {roads[0]}
          </text>
          <text x="380" y="520" fontSize="13" letterSpacing="1" transform="rotate(-90 380 520)" className="fill-muted-foreground">
            {roads[1]}
          </text>
        </>
      ) : null}

      {station ? (
        <>
          <rect x="220" y="200" width="96" height="40" className="fill-foreground" />
          <text x="268" y="225" fontSize="14" textAnchor="middle" fontWeight="500" className="fill-background">
            {station}
          </text>
          {exitNo ? (
            <>
              <circle cx="316" cy="252" r="11" strokeWidth="1.5" className="fill-background stroke-foreground" />
              <text x="316" y="256.5" fontSize="12" textAnchor="middle" fontWeight="600" className="fill-foreground">
                {exitNo}
              </text>
            </>
          ) : null}
          {exit ? (
            <text x="236" y="272" fontSize="12" className="fill-muted-foreground">
              {exit}
            </text>
          ) : null}
          <path d="M328 252 L 362 252 L 362 410 L 470 410 L 470 382" fill="none" strokeWidth="2.5" strokeDasharray="2 7" strokeLinecap="round" className="stroke-primary" />
        </>
      ) : null}

      <rect x="430" y="300" width="80" height="80" className="fill-primary" />
      <rect x="410" y="330" width="120" height="30" className="fill-background" />
      <text x="470" y="350" fontSize="14" textAnchor="middle" fontWeight="600" className="fill-primary">
        {place}
      </text>
    </svg>
  )
}

function CopyButton({ text, label, done }: { text: string; label: string; done: string }) {
  const [copied, setCopied] = useState(false)
  const timer = useRef<ReturnType<typeof setTimeout>>(undefined)
  useEffect(() => () => clearTimeout(timer.current), [])
  const copy = async () => {
    try {
      await navigator.clipboard.writeText(text)
    } catch {
      const t = document.createElement('textarea')
      t.value = text
      t.style.position = 'fixed'
      t.style.opacity = '0'
      document.body.appendChild(t)
      t.select()
      document.execCommand('copy')
      t.remove()
    }
    setCopied(true)
    clearTimeout(timer.current)
    timer.current = setTimeout(() => setCopied(false), 2000)
  }
  return (
    <button
      type="button"
      onClick={copy}
      className="mt-3 inline-flex h-9 items-center gap-1.5 rounded-md border border-input px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
    >
      <svg aria-hidden viewBox="0 0 24 24" className="size-4" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        {copied ? (
          <path d="M5 12.5l4.5 4.5L19 7.5" />
        ) : (
          <>
            <rect x="8.5" y="8.5" width="11" height="11" rx="1.5" />
            <path d="M15.5 8.5V6a1.5 1.5 0 0 0-1.5-1.5H6A1.5 1.5 0 0 0 4.5 6v8A1.5 1.5 0 0 0 6 15.5h2.5" />
          </>
        )}
      </svg>
      <span aria-live="polite">{copied ? done : label}</span>
    </button>
  )
}

export function Location({
  address,
  title,
  eyebrow,
  description,
  rows = [],
  map,
  children,
  sketch,
  mapLinks = [],
  phone,
  addressLabel = '주소',
  copyLabel = '주소 복사',
  copiedLabel = '복사했습니다',
  className = '',
}: LocationProps) {
  const custom = map ?? children
  return (
    <section className={`py-16 md:py-24 ${className}`}>
      <div className="shell">
        {title ? <SectionHead title={title} eyebrow={eyebrow} description={description} className="mb-12" /> : null}
        <div className="grid gap-10 md:grid-cols-12">
          <div className="aspect-[4/3] overflow-hidden rounded-lg bg-muted md:col-span-7 [&>iframe]:h-full [&>iframe]:w-full [&>iframe]:border-0 [&>img]:h-full [&>img]:w-full [&>img]:object-cover">
            {custom ?? <MapSketch place={sketch?.place ?? ''} {...sketch} />}
          </div>

          <div className="md:col-span-5">
            <dl>
              <div className="grid grid-cols-[4.5rem_1fr] gap-4 border-y border-border py-5 md:border-t-0 md:pt-0">
                <dt className="text-sm font-medium text-primary">{addressLabel}</dt>
                <dd className="text-[15px] leading-[1.75]">
                  {address}
                  <br />
                  <CopyButton text={address} label={copyLabel} done={copiedLabel} />
                </dd>
              </div>
              {rows.map((r) => (
                <div key={r.label} className="grid grid-cols-[4.5rem_1fr] gap-4 border-b border-border py-5">
                  <dt className="text-sm font-medium text-primary">{r.label}</dt>
                  <dd className="text-[15px] leading-[1.75]">{r.value}</dd>
                </div>
              ))}
            </dl>

            {mapLinks.length ? (
              <ul className="mt-6 flex flex-wrap gap-2">
                {mapLinks.map((l) => (
                  <li key={l.label}>
                    <a
                      href={l.href}
                      target="_blank"
                      rel="noopener noreferrer"
                      className="inline-flex h-11 items-center gap-1.5 rounded-lg border border-input px-4 text-sm font-medium transition-colors hover:border-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
                    >
                      {l.label}
                      <svg aria-hidden viewBox="0 0 24 24" className="size-4 text-muted-foreground" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
                        <path d="M9 6.5h8.5V15M17.5 6.5 6.5 17.5" />
                      </svg>
                    </a>
                  </li>
                ))}
              </ul>
            ) : null}

            {phone ? (
              <a
                href={`tel:${phone.number.replace(/[^0-9+]/g, '')}`}
                className="mt-10 flex items-baseline justify-between gap-4 border-t border-foreground pt-5 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
              >
                <span className="text-sm text-muted-foreground">{phone.label}</span>
                <span className="text-2xl font-medium tracking-[-0.01em] tabular-nums">{phone.number}</span>
              </a>
            ) : null}
          </div>
        </div>
      </div>
    </section>
  )
}

함께 쓰는 부품