Skip to content

Commit d01f06b

Browse files
committed
intial approach for style hierarchy fix
1 parent 1c2cb7d commit d01f06b

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

packages/app/src/App.js

+26-5
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,35 @@ class App extends Component {
5555
return null;
5656
}
5757

58+
// First problem: Text style hierarchy doesn't work (it should render in orange)
59+
// Second problem: View positions aren't correctly geometrically
60+
// Third problem: View backgroundColor isn't correct, 2nd View should have same bgc as 1st
61+
// and also 4th should have same as 3rd
5862
return (
59-
<View style={styles.surface}>
60-
<Clock />
61-
<Sidebar />
62-
<Slideshow />
63-
<Grid />
63+
<View style={{width: 80, height: 80, backgroundColor: 'grey', color: 'orange'}}>
64+
<View>
65+
<View style={{width: 80, height: 80, backgroundColor: 'powderblue'}}>
66+
<View
67+
style={{
68+
width: 30,
69+
height: 30
70+
}}
71+
>
72+
<Text>should be in orange</Text>
73+
</View>
74+
</View>
75+
</View>
6476
</View>
6577
);
78+
79+
// return (
80+
// <View style={styles.surface}>
81+
// <Clock />
82+
// <Sidebar />
83+
// <Slideshow />
84+
// <Grid />
85+
// </View>
86+
// );
6687
}
6788
}
6889

packages/app/src/Sidebar.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ class Sidebar extends Component {
6363
text="Rio de Janeiro"
6464
idx={120}
6565
/>
66-
<FocusableItem focusKey="sidebar-item-2" text="Kyoto" idx={160} />
66+
<FocusableItem focusKey="sidebar-item-2" text="京都" idx={160} />
6767
<FocusableItem focusKey="sidebar-item-3" text="Stockholm" idx={200} />
68+
<FocusableItem focusKey="sidebar-item-4" text="Phoenix" idx={240} />
69+
<FocusableItem focusKey="sidebar-item-5" text="नई दिल्ली" idx={280} />
70+
<FocusableItem focusKey="sidebar-item-6" text="Cusco" idx={320} />
6871
{/*</View>*/}
6972
</View>
7073
);

packages/react-ape/__tests__/layout-test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {render, View} from '../reactApeEntry';
33
import testCanvasSnapshot from '../../../tests/testCanvasSnapshot';
44

55
describe('Layout test', () => {
6-
describe('Test "relative" and "absolute" <Views/>', () => {
6+
describe('Test "relative" and "absolute" Views', () => {
77
test('Test 5 views with different positions (4 relative and 1 absolute)', () => {
88
const canvas = document.createElement('canvas');
99
canvas.height = 600;
@@ -68,6 +68,8 @@ describe('Layout test', () => {
6868

6969
render(<Layout />, canvas, () => testCanvasSnapshot(expect, canvas));
7070
});
71+
});
72+
describe('BorderRadius', () => {
7173
test('Test 2 View with BorderRadius', () => {
7274
const canvas = document.createElement('canvas');
7375
canvas.height = 600;

packages/react-ape/renderer/core/render.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@ function renderApeQueue(
2323
) {
2424
if (apeContextGlobal && apeContextGlobal.renderQueue.length) {
2525
const queue = apeContextGlobal.renderQueue;
26-
let req;
2726

27+
let reqId;
2828
const frame = () => {
29-
req = requestAnimationFrame(frame);
30-
const element = queue.shift();
31-
element.render(apeContextGlobal, element.parentLayout);
29+
if (queue.length) {
30+
const element = queue.shift();
31+
element.render(apeContextGlobal, element.parentLayout);
3232

33-
requestAnimationFrame(frame);
34-
35-
if (!queue.length) {
36-
cancelAnimationFrame(req);
33+
reqId = requestAnimationFrame(frame);
34+
} else {
35+
cancelAnimationFrame(reqId);
3736
onFinish();
3837
}
3938
};

tests/setup.js

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const jsdom = new JSDOM('<!doctype html><html><body></body></html>', {
66
url: 'http://localhost/',
77
});
88
const { window } = jsdom;
9+
window.requestAnimationFrame = (cb) => window.setTimeout(cb, 1000 / 60);
10+
window.cancelAnimationFrame = () => null;
911

1012
function copyProps(src, target) {
1113
const props = Object.getOwnPropertyNames(src)

0 commit comments

Comments
 (0)