Skip to content

Commit

Permalink
Merge pull request #8 from vitalics/1.4.x/fmt
Browse files Browse the repository at this point in the history
fmt(patch): update jsx properties in common components
core(release): update release script
  • Loading branch information
vitalics authored Sep 22, 2022
2 parents 1aac5b5 + 9d3f4db commit a5d04cc
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ jobs:
git config --global user.email "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
echo "GIT_USER=${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
- run: pnpm release --type ${{ github.event.inputs.release_type || 'patch' }}
- run: |
TAG=`git describe --tags --abbrev=0`
RELEASE_LOG=$(<./releases/$TAG.md)
- uses: fregante/release-with-changelog@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-template: "- {title} ← {hash}"
template: |
### Changelog
$RELEASE_LOG
### PRs
{commits}
Full changelog: {range}
See [Previous releases](https://github.com/vitalics/Telegraph/tree/main/releases)
Expand Down
1 change: 1 addition & 0 deletions packages/docs/docs/tutorial/fmt/jsx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ Better to wrap high-level component with `Fragment` component from `preact` libr
- Each reply context should be call `render` function. As for previous limitation `render` function only for your using context.
- `render` function in `default` function should be called with `rest/spread` operator, since `reply` function accepts text modifications(like bold, underline, etc.)
- not all components can be combined with children(e.g. `Bold` and `Italic` can be combined)
- do not crate component with many hierarchies. Better to use 1 hierary without depths.
6 changes: 3 additions & 3 deletions packages/fmt/common/command.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Fragment, h, JSX } from 'preact';

type Props = {
children: string | JSX.Element
name: string;
};

/**
Expand All @@ -16,6 +16,6 @@ type Props = {
* @param {(S)} str command name
* @return {*} string
*/
export default function ({ children }: Props) {
return <Fragment>/{children}</Fragment>
export default function ({ name }: Props) {
return <Fragment>/{name}</Fragment>
}
6 changes: 3 additions & 3 deletions packages/fmt/common/hash.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Fragment, h, JSX } from 'preact';

type Props = {
children: string | JSX.Element;
hash: string;
};

export default function ({ children }: Props) {
return <Fragment>#{children}</Fragment>;
export default function ({ hash }: Props) {
return <Fragment>#{hash}</Fragment>;
}
6 changes: 3 additions & 3 deletions packages/fmt/common/mention.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Fragment, h, JSX } from 'preact';

type Props = {
children: string;
username: string;
};

/**
Expand All @@ -13,6 +13,6 @@ type Props = {
* <Mention>some_user_name</Mention>
* // same as '@some_user_name'
*/
export default function ({ children }: Props) {
return <Fragment>@{children}</Fragment>;
export default function ({ username }: Props) {
return <Fragment>@{username}</Fragment>;
}
14 changes: 5 additions & 9 deletions packages/fmt/common/phone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import toString from 'preact-render-to-string'
import { parsePhoneNumber, type PhoneNumberFormat } from 'awesome-phonenumber';

export type Props = {
children: string | JSX.Element;
number: string | number | `+${number}`;
format?: PhoneNumberFormat;
/**
* Region code for the phone number (only required if phoneNumber is on a national format). Example: 'SE' for Sweden, 'CH' for Switzerland, etc.
Expand All @@ -25,15 +25,11 @@ export type Props = {
* @return {string} Phone number
*/
export default function (props: Props) {
let phoneNumber: string;
if (typeof props.children === 'object') {
phoneNumber = toString(props.children);
} else {
phoneNumber = props.children.toString();
}
const parsed = parsePhoneNumber(phoneNumber, props?.regionCode)
const phoneNumber = props.number.toString();

const parsed = parsePhoneNumber(phoneNumber, props?.regionCode);
if (!parsed.isValid()) {
throw new TypeError(`Phone "${props.children}" number is not valid`)
throw new TypeError(`Phone "${phoneNumber}" number is not valid`)
}
return <Fragment>{parsed.getNumber(props?.format)}</Fragment>;
}
12 changes: 12 additions & 0 deletions upcoming.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
## core

- add release log for new releases

## packages

[@tlgr/docs]

- Add one more limitation about using JSX

[@tlgr/fmt]

- replace children properties from common components to another properties.

0 comments on commit a5d04cc

Please sign in to comment.