@platformatic/ui-components 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -5,30 +5,32 @@ import ApiDetails from './src/components/ApiDetail'
5
5
  import BorderedBox from './src/components/BorderedBox'
6
6
  import BorderedText from './src/components/BorderedText'
7
7
  import HorizontalSeparator from './src/components/HorizontalSeparator'
8
+ import GHLoginButton from './src/components/GHLoginButton'
8
9
  import Layout from './src/components/layouts/Layout'
10
+ import LoginButton from './src/components/LoginButton'
9
11
  import TwoColumnsLayout from './src/components/layouts/TwoColumnsLayout'
10
12
  import Playground from './src/components/Playground'
11
- import Prs from './src/components/Pr'
13
+ import PullRequest from './src/components/PullRequest'
12
14
  import SearchBar from './src/components/SearchBar'
13
15
  import TabbedWindow from './src/components/TabbedWindow'
16
+ import TextWithLabel from './src/components/TextWithLabel'
14
17
  import Versions from './src/components/Versions'
15
18
  import VerticalSeparator from './src/components/VerticalSeparator'
16
- import LoginButton from './src/components/LoginButton'
17
- import GHLoginButton from './src/components/GHLoginButton'
18
19
  export {
19
20
  ApiSummary,
20
21
  ApiDetails,
21
22
  BorderedBox,
22
23
  BorderedText,
24
+ GHLoginButton,
23
25
  HorizontalSeparator,
24
26
  Layout,
27
+ LoginButton,
25
28
  TwoColumnsLayout,
26
29
  Playground,
27
- Prs,
30
+ PullRequest,
28
31
  SearchBar,
29
32
  TabbedWindow,
33
+ TextWithLabel,
30
34
  Versions,
31
- VerticalSeparator,
32
- LoginButton,
33
- GHLoginButton
35
+ VerticalSeparator
34
36
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@platformatic/ui-components",
3
3
  "description": "Platformatic UI Components",
4
- "version": "0.1.8",
4
+ "version": "0.1.10",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "scripts": {
@@ -6,8 +6,10 @@ import BorderedText from './BorderedText'
6
6
  import HorizontalSeparator from './HorizontalSeparator'
7
7
  import TwoColumnsLayout from './layouts/TwoColumnsLayout'
8
8
  import StatsView from './StatsView'
9
+ import TextWithLabel from './TextWithLabel'
9
10
  import VerticalSeparator from './VerticalSeparator'
10
11
  import React from 'react'
12
+ import styles from './ApiDetail.module.css'
11
13
  export default function ApiDetails (props) {
12
14
  const { url, repository, version, openapi, graphql, source, lastDeploy } = props
13
15
  const requestStats = {
@@ -55,20 +57,22 @@ export default function ApiDetails (props) {
55
57
  return (
56
58
  <>
57
59
  <BorderedBox classes='api-data'>
58
- <div>
59
- Preview/Staging URL: <a href={url}>{url}</a>
60
- </div>
61
- <div>
62
- Repository: <a href={`https://github.com/${repository}`}>{repository}</a>
63
- </div>
64
- <div>
65
- Version: <BorderedText text={`v${version}`} />
60
+ <div className={styles.main}>
61
+ <div>
62
+ Preview/Staging URL: <a href={url}>{url}</a>
63
+ </div>
64
+ <div>
65
+ Repository: <a href={`https://github.com/${repository}`}>{repository}</a>
66
+ </div>
67
+ <div>
68
+ Version: <BorderedText text={`v${version}`} />
69
+ </div>
66
70
  </div>
67
71
  <HorizontalSeparator />
68
72
  <div className='flex gap-2 items-center'>
69
- <span>Generated with: {source}</span>
73
+ <TextWithLabel label='Generated With' text={source} />
70
74
  <VerticalSeparator />
71
- <span>Last deployed: {lastDeploy}</span>
75
+ <TextWithLabel label='Last deployed' text={lastDeploy} />
72
76
  </div>
73
77
  <div className='flex items-center'>
74
78
  <span className='mr-2'>Endpoints: </span><Endpoints graphql={graphql} openapi={openapi} />
@@ -0,0 +1,3 @@
1
+ .main {
2
+ @apply flex flex-col gap-y-4;
3
+ }
@@ -4,9 +4,10 @@ import ApiFooter from './Api/Footer'
4
4
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
5
5
  import { faLink } from '@fortawesome/free-solid-svg-icons'
6
6
  import ApiVersion from './Api/Version'
7
- import ApiIcon from './Api/ApiIcon'
8
- import ApiIconClosed from './Api/ApiIconClosed'
9
- import Separator from './VerticalSeparator'
7
+ import ApiIcon from './icons/ApiIcon'
8
+ import ApiIconClosed from './icons/ApiIconClosed'
9
+ import VerticalSeparator from './VerticalSeparator'
10
+ import TextWithLabel from './TextWithLabel'
10
11
  import ApiStatus from './Api/Status'
11
12
  import BorderedBox from './BorderedBox'
12
13
  import HorizontalSeparator from './HorizontalSeparator'
@@ -46,9 +47,9 @@ export default function ApiSummary (props) {
46
47
  </div>
47
48
 
48
49
  <div className='flex gap-2 items-center'>
49
- <span>Generated with: {source}</span>
50
- <Separator />
51
- <span>Last deployed: {lastDeploy}</span>
50
+ <TextWithLabel label='Generated With' text={source} />
51
+ <VerticalSeparator />
52
+ <TextWithLabel label='Last deployed' text={lastDeploy} />
52
53
  </div>
53
54
  </div>
54
55
 
@@ -4,7 +4,7 @@ import SearchBar from './SearchBar'
4
4
  import Api from './Api'
5
5
  import ApiDetails from './ApiDetail'
6
6
  import TabbedWindow from './TabbedWindow'
7
- import Prs from './Pr'
7
+ import Prs from './PullRequest'
8
8
  import Playground from './Playground'
9
9
  import Versions from './Versions'
10
10
  import React, { useState } from 'react'
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+ import React from 'react'
3
+ import BorderedBox from './BorderedBox'
4
+ import HorizontalSeparator from './HorizontalSeparator'
5
+ import PullRequestIcon from './icons/PullRequestIcon'
6
+ import styles from './PullRequest.module.css'
7
+ import TextWithLabel from './TextWithLabel'
8
+ import VerticalSeparator from './VerticalSeparator'
9
+ export default function PullRequest ({ id, title, lastCommit, url }) {
10
+ return (
11
+ <BorderedBox color='green'>
12
+ <div className={styles.header}>
13
+ <PullRequestIcon />
14
+ <span className={styles.id}>#{id}</span>
15
+ <span><a href={url} target='_blank' rel='noreferrer'>{url}</a></span>
16
+ </div>
17
+ <div className={styles.content}>
18
+ <TextWithLabel label='PR Title' text={title} />
19
+ </div>
20
+
21
+ <HorizontalSeparator />
22
+ <div className={styles.footer}>
23
+ <TextWithLabel label='Last commit by' text={lastCommit.author} />
24
+ <VerticalSeparator />
25
+ <TextWithLabel label='Commit SHA' text={lastCommit.sha} />
26
+ <VerticalSeparator />
27
+ <TextWithLabel label='Last Update' text={lastCommit.date} />
28
+ </div>
29
+ </BorderedBox>
30
+ )
31
+ }
@@ -0,0 +1,12 @@
1
+ .container {
2
+ @apply flex flex-col;
3
+ }
4
+ .id {
5
+ @apply text-xl text-main-green font-semibold;
6
+ }
7
+ .header {
8
+ @apply flex items-center gap-x-4 mb-4;
9
+ }
10
+ .footer {
11
+ @apply flex items-center
12
+ }
@@ -6,15 +6,23 @@ import styles from './SearchBar.module.css'
6
6
  import commonStyles from './Common.module.css'
7
7
  export default function SearchBar (props) {
8
8
  const inputRef = useRef()
9
- const { action } = props
10
-
9
+ const { onSubmit, onChange } = props
11
10
  function handleSearch () {
12
- const value = inputRef.current.value
13
- return action(value)
11
+ if (onSubmit) {
12
+ const value = inputRef.current.value
13
+ return onSubmit(value)
14
+ }
15
+ }
16
+
17
+ function handleChange () {
18
+ if (onChange) {
19
+ const value = inputRef.current.value
20
+ return onChange(value)
21
+ }
14
22
  }
15
23
  return (
16
24
  <div className={`${styles.input} ${commonStyles.padded}`}>
17
- <input type='text' placeholder='Search' className='grow' ref={inputRef} />
25
+ <input type='text' placeholder='Search' className='grow' ref={inputRef} onChange={handleChange} />
18
26
  <button onClick={handleSearch}>
19
27
  <FontAwesomeIcon color='white' icon={faSearch} />
20
28
  </button>
@@ -22,7 +22,7 @@ export default function TabbedWindow (props) {
22
22
  <div className={styles['tabs-header']}>
23
23
  {headers.map((header, index) => {
24
24
  return (
25
- <span onClick={() => setSelected(index)} key={index} className={selected === index ? styles['selected-tab'] : ''}>
25
+ <span onClick={() => setSelected(index)} key={index} className={`${styles.tab} ${selected === index ? styles['selected-tab'] : ''}`}>
26
26
  {header}
27
27
  </span>
28
28
  )
@@ -3,8 +3,15 @@
3
3
  }
4
4
 
5
5
  .tabs-header {
6
- @apply flex justify-between text-white uppercase hover:cursor-pointer mb-4 tracking-[.25rem] h-[4rem];
6
+ @apply flex justify-start text-white uppercase hover:cursor-pointer mb-4 tracking-[.25rem] h-[2rem];
7
+ }
8
+ .tab {
9
+ @apply mr-4 min-w-[105px] text-center;
7
10
  }
8
11
  .selected-tab {
9
12
  @apply underline text-main-green underline-offset-8 font-bold;
13
+ }
14
+
15
+ .tabs-content {
16
+ @apply h-screen
10
17
  }
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import styles from './TextWithLabel.module.css'
3
+ export default function TextWithLabel ({ label, text, children }) {
4
+ return (
5
+ <div className={styles.container}>
6
+ <span className={styles.label}>{label}:</span>
7
+ {text && <span className={styles.text}>{text}</span>}
8
+ {children && <span>{children}</span>}
9
+ </div>
10
+ )
11
+ }
@@ -0,0 +1,9 @@
1
+ .container {
2
+ @apply text-white
3
+ }
4
+ .label {
5
+ @apply font-thin mr-2;
6
+ }
7
+ .text {
8
+ @apply font-semibold;
9
+ }
File without changes
File without changes
@@ -0,0 +1,31 @@
1
+ import * as React from 'react'
2
+
3
+ const PullRequestIcon = () => (
4
+ <svg
5
+ width={40}
6
+ height={40}
7
+ fill='none'
8
+ xmlns='http://www.w3.org/2000/svg'
9
+ >
10
+ <circle cx={9.5} cy={30.5} r={4.5} stroke='#fff' strokeWidth={2} />
11
+ <circle cx={9.5} cy={9.5} r={4.5} stroke='#fff' strokeWidth={2} />
12
+ <path stroke='#fff' strokeWidth={2} d='M9 14v12' />
13
+ <circle cx={30.5} cy={30.5} r={4.5} stroke='#fff' strokeWidth={2} />
14
+ <path
15
+ d='M30.5 26V10.5a1 1 0 0 0-1-1H23'
16
+ stroke='#fff'
17
+ strokeWidth={2}
18
+ strokeLinecap='round'
19
+ strokeLinejoin='round'
20
+ />
21
+ <path
22
+ d='m26 5-4.5 4.5L26 14'
23
+ stroke='#fff'
24
+ strokeWidth={2}
25
+ strokeLinecap='round'
26
+ strokeLinejoin='round'
27
+ />
28
+ </svg>
29
+ )
30
+
31
+ export default PullRequestIcon
@@ -3,7 +3,7 @@ import React from 'react'
3
3
 
4
4
  export default function Layout (props) {
5
5
  return (
6
- <div className='container mx-auto px-4 my-5 flex flex-col gap-10'>
6
+ <div className='container mx-auto px-4 my-5 flex flex-col gap-10 h-screen'>
7
7
  {props.children}
8
8
  </div>
9
9
 
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+ import PullRequest from '../components/PullRequest'
3
+ export default {
4
+ title: 'Platformatic/PullRequest',
5
+ component: PullRequest,
6
+ argTypes: {
7
+ color: { control: 'color' }
8
+ }
9
+ }
10
+
11
+ const Template = (args) => <PullRequest {...args}>Hello Platformatic</PullRequest>
12
+
13
+ export const Standard = Template.bind({})
14
+ Standard.args = {
15
+ id: '88',
16
+ title: 'doc: host => hostname, binded to 0.0.0.0 to be more container friendly',
17
+ url: 'http://example.com',
18
+ lastCommit: {
19
+ sha: 'bgb3ffe3',
20
+ author: 'Foobar',
21
+ date: '2022-10-11'
22
+ }
23
+ }
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+ import SearchBar from '../components/SearchBar'
3
+ export default {
4
+ title: 'Platformatic/SearchBar',
5
+ component: SearchBar,
6
+ argTypes: {
7
+ onChange: { control: 'function' },
8
+ onSubmit: { control: 'function' }
9
+ }
10
+ }
11
+ const Template = (args) => {
12
+ return (
13
+ <>
14
+ <SearchBar {...args}>Hello Platformatic</SearchBar>
15
+ </>
16
+
17
+ )
18
+ }
19
+ export const Standard = Template.bind({})
20
+ Standard.args = {
21
+ onChange: (value) => {
22
+ console.log('Current search: ' + value)
23
+ },
24
+ onSubmit: (value) => {
25
+ alert('Query value: ' + value)
26
+ }
27
+ }
@@ -0,0 +1,25 @@
1
+ 'use strict'
2
+
3
+ import TextWithLabel from '../components/TextWithLabel'
4
+ export default {
5
+ title: 'Platformatic/TextWithLabel',
6
+ component: TextWithLabel,
7
+ argTypes: {
8
+ label: { control: 'text' },
9
+ text: { control: 'text' }
10
+ }
11
+ }
12
+ const Template = (args) => <TextWithLabel {...args} />
13
+
14
+ export const Standard = Template.bind({})
15
+
16
+ Standard.args = {
17
+ label: 'Created By',
18
+ text: 'Platformatic Team'
19
+ }
20
+
21
+ export const WithLink = (args) => <TextWithLabel {...args}><a href='https://example.com'>Standard Link</a></TextWithLabel>
22
+
23
+ WithLink.args = {
24
+ label: 'External Link'
25
+ }
@@ -1,9 +0,0 @@
1
- 'use strict'
2
- import React from 'react'
3
- import BorderedBox from './BorderedBox'
4
-
5
- export default function Prs () {
6
- return (
7
- <BorderedBox color='green'>PR</BorderedBox>
8
- )
9
- }