From f717db5428f3b22f8510d7b740f542585c267820 Mon Sep 17 00:00:00 2001 From: zealotchen Date: Thu, 20 Jun 2024 21:47:07 +0800 Subject: [PATCH] feat(react): add font style inherit --- .../src/components/Text/index.jsx | 16 ++++++++--- .../src/components/demos/demo-p.vue | 17 +++++++++++- .../hippy-react/src/dom/element-node.ts | 6 +++++ .../hippy-react/src/renderer/render.ts | 22 +++++++++++++-- .../packages/hippy-react/src/utils/index.ts | 8 ++++++ .../js/packages/hippy-react/src/utils/node.ts | 5 ++++ .../js/packages/hippy-vue/src/native/index.ts | 27 ++++++++++++------- .../hippy-vue/src/renderer/element-node.ts | 15 +++++++++-- driver/js/packages/hippy-vue/src/util/node.ts | 5 ++++ 9 files changed, 103 insertions(+), 18 deletions(-) diff --git a/driver/js/examples/hippy-react-demo/src/components/Text/index.jsx b/driver/js/examples/hippy-react-demo/src/components/Text/index.jsx index bcab4c11232..989240d6869 100644 --- a/driver/js/examples/hippy-react-demo/src/components/Text/index.jsx +++ b/driver/js/examples/hippy-react-demo/src/components/Text/index.jsx @@ -77,6 +77,7 @@ export default class TextExpo extends React.Component { x: 1, y: 1, }, + scrollColor: 'gray', numberOfLines: 2, ellipsizeMode: undefined, }; @@ -85,6 +86,7 @@ export default class TextExpo extends React.Component { this.incrementLine = this.incrementLine.bind(this); this.decrementLine = this.decrementLine.bind(this); this.changeMode = this.changeMode.bind(this); + this.changeColor = this.changeColor.bind(this); } incrementFontSize() { @@ -129,19 +131,24 @@ export default class TextExpo extends React.Component { this.setState({ ellipsizeMode: mode }); } + changeColor() { + this.setState({ scrollColor: 'red' }); + } + changeBreakStrategy(breakStrategy) { this.setState({ breakStrategy }); } render() { - const { fontSize, textShadowColor, textShadowOffset, numberOfLines, ellipsizeMode, breakStrategy } = this.state; + const { fontSize, textShadowColor, textShadowOffset, numberOfLines, ellipsizeMode, breakStrategy, + scrollColor } = this.state; const renderTitle = title => ( {title} ); return ( - + {renderTitle('shadow')} { let textShadowColor = 'red'; @@ -173,10 +180,13 @@ export default class TextExpo extends React.Component { This is red {renderTitle('fontSize')} - + { `Text fontSize is ${fontSize}` } + + 切换字体颜色 + 放大字体 diff --git a/driver/js/examples/hippy-vue-demo/src/components/demos/demo-p.vue b/driver/js/examples/hippy-vue-demo/src/components/demos/demo-p.vue index aa410456f41..966a5b7885c 100644 --- a/driver/js/examples/hippy-vue-demo/src/components/demos/demo-p.vue +++ b/driver/js/examples/hippy-vue-demo/src/components/demos/demo-p.vue @@ -1,5 +1,8 @@