-
-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: nesting ol and ul will result in disinct bullet style types
The list renderer can now be extended with getListStyleTypeFromNestLevel prop. resolves #312
- Loading branch information
Showing
11 changed files
with
146 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable react-hooks/rules-of-hooks */ | ||
import React, { PropsWithChildren } from 'react'; | ||
|
||
const OlNestLevel = React.createContext<number>(0); | ||
const UlNestLevel = React.createContext<number>(0); | ||
|
||
export function useListNestLevel(listType: 'ol' | 'ul') { | ||
return listType === 'ol' | ||
? React.useContext(OlNestLevel) | ||
: React.useContext(UlNestLevel); | ||
} | ||
|
||
export interface NestLevelProviderProps { | ||
listType: 'ol' | 'ul'; | ||
level: number; | ||
} | ||
|
||
export default function NestLevelProvider({ | ||
listType, | ||
level, | ||
children | ||
}: PropsWithChildren<NestLevelProviderProps>) { | ||
if (listType === 'ol') { | ||
return ( | ||
<OlNestLevel.Provider value={level}>{children}</OlNestLevel.Provider> | ||
); | ||
} | ||
return <UlNestLevel.Provider value={level}>{children}</UlNestLevel.Provider>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/render-html/src/elements/__tests__/numOfCharsInPrefix.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import numOfCharsInPrefix from '../numOfCharsInPrefix'; | ||
|
||
describe('numOfCharsInPrefix', () => { | ||
it('should handle length of 1', () => { | ||
expect(numOfCharsInPrefix(1, 10)).toEqual(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters