Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #346 from gluestack/release/@gluestack-style/react…
Browse files Browse the repository at this point in the history
…@0.2.9

Release/@gluestack style/[email protected]
  • Loading branch information
Viraj-10 authored Aug 25, 2023
2 parents 5e3f9a7 + e56d116 commit cdbe07a
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 98 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: "Unit test"
run-name: "Unit Test"
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
# name: 'Unit test'
# run-name: 'Unit Test'
# on: [pull_request]
# jobs:
# test:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2

- uses: actions/setup-node@v3
with:
node-version: 16.x
# - uses: actions/setup-node@v3
# with:
# node-version: 16.x

- name: Print Repo Name
run: echo ${{ github.event.client_payload.message.repo }}
# - name: Print Repo Name
# run: echo ${{ github.event.client_payload.message.repo }}

- name: Install Dependencies
run: yarn
- name: Run Tests
run: yarn test
# - name: Install Dependencies
# run: yarn

# - name: Run Tests
# run: yarn test
2 changes: 1 addition & 1 deletion packages/animation-plugin/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export function resolveStringToken(
return tokenValue;
} else {
if (tokenScaleMap[propName]) {
if (!config || !config.tokens || !config.tokens[token_scale]) {
if (!config || !config.tokens) {
throw new Error(
'You cannot use tokens without wrapping the component with StyledProvider. Please wrap the component with a StyledProvider and pass theme config.'
);
Expand Down
6 changes: 6 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @gluestack-style/react

## 0.2.9

### Patch Changes

- fix: customizing component specififcity issue

## 0.2.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@gluestack-style/react",
"description": "A universal & performant styling library for React Native, Next.js & React",
"version": "0.2.6",
"version": "0.2.9",
"keywords": [
"React Native",
"Next.js",
Expand Down
116 changes: 88 additions & 28 deletions packages/react/src/resolver/getComponentStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,107 @@ import type { OrderedSXResolved } from '../types';
export function getComponentResolvedBaseStyle(
orderedResolved: OrderedSXResolved
) {
return orderedResolved.filter(
(item: any) =>
!item.meta.path?.includes('descendants') &&
!(
item.meta.path?.includes('variants') ||
item.meta.path?.includes('compoundVariants')
)
);
const componentOrderResolvedBaseStyle: Array<any> = [];
const componentOrderResolvedBaseStateStyle: Array<any> = [];

orderedResolved &&
orderedResolved.forEach((item: any) => {
if (
!item.meta.path?.includes('descendants') &&
!(
item.meta.path?.includes('variants') ||
item.meta.path?.includes('compoundVariants')
)
) {
if (item.meta.path?.includes('state')) {
componentOrderResolvedBaseStateStyle.push(item);
} else {
componentOrderResolvedBaseStyle.push(item);
}
}
});
return [
componentOrderResolvedBaseStyle,
componentOrderResolvedBaseStateStyle,
];
}

export function getComponentResolvedVariantStyle(
orderedResolved: OrderedSXResolved
) {
return orderedResolved.filter(
(item: any) =>
!item.meta.path?.includes('descendants') &&
(item.meta.path?.includes('variants') ||
item.meta.path?.includes('compoundVariants'))
);
const componentOrderResolvedVariantStyle: Array<any> = [];
const componentOrderResolvedVariantStateStyle: Array<any> = [];

orderedResolved &&
orderedResolved.forEach((item: any) => {
if (
!item.meta.path?.includes('descendants') &&
(item.meta.path?.includes('variants') ||
item.meta.path?.includes('compoundVariants'))
) {
if (item.meta.path?.includes('state')) {
componentOrderResolvedVariantStateStyle.push(item);
} else {
componentOrderResolvedVariantStyle.push(item);
}
}
});
return [
componentOrderResolvedVariantStyle,
componentOrderResolvedVariantStateStyle,
];
}

export function getDescendantResolvedBaseStyle(
orderedResolved: OrderedSXResolved
) {
return orderedResolved.filter(
(item: any) =>
item.meta.path?.includes('descendants') &&
!(
item.meta.path?.includes('variants') ||
item.meta.path?.includes('compoundVariants')
)
);
const descendantOrderResolvedBaseStyle: Array<any> = [];
const descendantOrderResolvedBaseStateStyle: Array<any> = [];

orderedResolved &&
orderedResolved.forEach((item: any) => {
if (
item.meta.path?.includes('descendants') &&
!(
item.meta.path?.includes('variants') ||
item.meta.path?.includes('compoundVariants')
)
) {
if (item.meta.path?.includes('state')) {
descendantOrderResolvedBaseStateStyle.push(item);
} else {
descendantOrderResolvedBaseStyle.push(item);
}
}
});
return [
descendantOrderResolvedBaseStyle,
descendantOrderResolvedBaseStateStyle,
];
}

export function getDescendantResolvedVariantStyle(
orderedResolved: OrderedSXResolved
) {
return orderedResolved.filter(
(item: any) =>
item.meta.path?.includes('descendants') &&
(item.meta.path?.includes('variants') ||
item.meta.path?.includes('compoundVariants'))
);
const descendantOrderResolvedVariantStyle: Array<any> = [];
const descendantOrderResolvedVariantStateStyle: Array<any> = [];

orderedResolved &&
orderedResolved.forEach((item: any) => {
if (
item.meta.path?.includes('descendants') &&
(item.meta.path?.includes('variants') ||
item.meta.path?.includes('compoundVariants'))
) {
if (item.meta.path?.includes('state')) {
descendantOrderResolvedVariantStateStyle.push(item);
} else {
descendantOrderResolvedVariantStyle.push(item);
}
}
});
return [
descendantOrderResolvedVariantStyle,
descendantOrderResolvedVariantStateStyle,
];
}
16 changes: 9 additions & 7 deletions packages/react/src/style-sheet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ export class StyleInjector {
) {
const styleIds: any = [];
orderedSXResolved.forEach((styledResolved: any) => {
this.#globalStyleMap.set(styledResolved.meta.cssId, {
...styledResolved,
type: _wrapperElementId,
componentHash: _styleTagId,
extendedConfig,
});
styleIds.push(styledResolved.meta.cssId);
if (styledResolved?.meta?.cssId) {
this.#globalStyleMap.set(styledResolved.meta.cssId, {
...styledResolved,
type: _wrapperElementId,
componentHash: _styleTagId,
extendedConfig,
});
styleIds.push(styledResolved.meta.cssId);
}
});

return styleIds;
Expand Down
22 changes: 3 additions & 19 deletions packages/react/src/styled.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable no-console */
import React, {
// JSXElementConstructor,
// Component,
useContext,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
import type {
ConfigType,
OrderedSXResolved,
// Styled,
StyleIds,
// DefaultAndState,
ComponentProps,
UtilityProps,
IVerbosedTheme,
Expand All @@ -29,7 +19,6 @@ import {
resolveStringToken,
shallowMerge,
deepMergeArray,
// deepMergeArray,
} from './utils';
import { convertUtilityPropsToSX } from './core/convert-utility-to-sx';
import { useStyled } from './StyledProvider';
Expand All @@ -39,12 +28,7 @@ import { INTERNAL_updateCSSStyleInOrderedResolved } from './updateCSSStyleInOrde
import { generateStylePropsFromCSSIds } from './generateStylePropsFromCSSIds';

import { get, onChange } from './core/colorMode';
import {
getComponentResolvedBaseStyle,
getComponentResolvedVariantStyle,
getDescendantResolvedBaseStyle,
getDescendantResolvedVariantStyle,
} from './resolver/getComponentStyle';

import { styledResolvedToOrderedSXResolved } from './resolver/orderedResolved';
import { styledToStyledResolved } from './resolver/styledResolved';
import { getStyleIds } from './resolver/getStyleIds';
Expand All @@ -58,7 +42,7 @@ import { stableHash } from './stableHash';
import { DeclarationType, GluestackStyleSheet } from './style-sheet';
import { CSSPropertiesMap } from './core/styled-system';
import { updateOrderUnResolvedMap } from './updateOrderUnResolvedMap';
// import { GluestackStyleSheet } from './style-sheet';

const styledSystemProps = { ...CSSPropertiesMap };

function isSubset(subset: any, set: any) {
Expand Down
8 changes: 8 additions & 0 deletions packages/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,21 @@ export type IWrapperType =
| 'forwarded-variant'
| 'forwarded-descendant-variant'
| 'boot-base'
| 'boot-base-state'
| 'boot-descendant-base'
| 'boot-descendant-base-state'
| 'boot-variant'
| 'boot-variant-state'
| 'boot-descendant-variant'
| 'boot-descendant-variant-state'
| 'extended-base'
| 'extended-base-state'
| 'extended-descendant-base'
| 'extended-descendant-base-state'
| 'extended-variant'
| 'extended-variant-state'
| 'extended-descendant-variant'
| 'extended-descendant-variant-state'
| 'passing-base'
| 'inline-base'
| 'inline-variant'
Expand Down
Loading

0 comments on commit cdbe07a

Please sign in to comment.