Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(RollingText): add RollingTextGroup #12572

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
79f1eb8
feat: RollingTextItem
nemo-shen Jan 15, 2024
328de36
feat: add rolling-text-group
nemo-shen Jan 16, 2024
ff8df6c
feat: add types
nemo-shen Jan 17, 2024
ba1feca
Merge branch 'main' into feature/rolling-text-item_0115
nemo-shen Jan 18, 2024
c951c2e
feat(RollingText): add rolling-text-group dir
nemo-shen Jan 25, 2024
fa1881c
Merge branch 'main' into feature/rolling-text-item_0115
nemo-shen Jan 25, 2024
f051711
feat(rolling-text-group): add 'auto-start' prop
nemo-shen Jan 25, 2024
9ea3668
chore: remove unuse file
nemo-shen Jan 25, 2024
266677e
feat(rolling-text): calc delay with parent
nemo-shen Jan 25, 2024
c1de023
feat(rolling-text-group): add 'stop-order' prop
nemo-shen Jan 25, 2024
2e9bdc1
feat(rolling-text-groups): add 'reset' method
nemo-shen Jan 25, 2024
8d4b48a
chore: remove unuse code
nemo-shen Jan 25, 2024
7bd67d0
fix(rolling-text): remove 'delay' prop
nemo-shen Jan 26, 2024
6dd26f6
feat(rolling-text-group): add props
nemo-shen Jan 26, 2024
ffb8fd2
chore: update demo
nemo-shen Jan 26, 2024
7a1fd45
docs: update readme
nemo-shen Jan 26, 2024
4374751
test: rolling-test
nemo-shen Jan 26, 2024
6b931c1
test: add rolling-text-group test cases
nemo-shen Jan 27, 2024
634846a
fix: reset method
nemo-shen Jan 27, 2024
f6e1a13
Merge branch 'main' into feature/rolling-text-item_0115
nemo-shen Jan 28, 2024
aa507a3
Merge branch 'main' into feature/rolling-text-item_0115
nemo-shen Jan 30, 2024
bb9b6e6
Merge branch 'main' into feature/rolling-text-item_0115
nemo-shen Feb 1, 2024
d4c2fc7
Merge branch 'main' into feature/rolling-text-item_0115
nemo-shen Feb 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions packages/vant/src/rolling-text-group/RollingTextGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {
defineComponent,
type InjectionKey,
type ExtractPropTypes,
PropType,
} from 'vue';

// Utils
import { truthProp, createNamespace, makeNumberProp } from '../utils';

// Composables
import { useChildren } from '@vant/use';
import { useExpose } from '../composables/use-expose';
import { RollingTextGroupExpose } from './types';
import { RollingTextDirection, RollingTextStopOrder } from '../rolling-text';

const [name, bem] = createNamespace('rolling-text-group');

export const rollingTextGroupProps = {
startNum: makeNumberProp(0),
duration: Number,
autoStart: truthProp,
direction: String as PropType<RollingTextDirection>,
stopOrder: String as PropType<RollingTextStopOrder>,
height: Number,
};

export type RollingTextGroupProps = ExtractPropTypes<
typeof rollingTextGroupProps
>;
export type RollingTextGroupProvide = {
props: RollingTextGroupProps;
};
export const ROLLING_TEXT_KEY: InjectionKey<RollingTextGroupProvide> =
Symbol(name);

export default defineComponent({
name,

props: rollingTextGroupProps,

setup(props, { slots }) {
const { children, linkChildren } = useChildren(ROLLING_TEXT_KEY);

linkChildren({
props,
});

const start = () => {
children.map((ins) => {
ins.start();
});
};

const reset = () => {
children.map((ins) => {
ins.reset();
});
};

useExpose<RollingTextGroupExpose>({
start,
reset,
});

if (slots.default) {
return () => <div class={bem()}>{slots.default!()}</div>;
}
},
});
15 changes: 15 additions & 0 deletions packages/vant/src/rolling-text-group/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { withInstall } from '../utils';
import _RollingTextGroup from './RollingTextGroup';

export const RollingTextGroup = withInstall(_RollingTextGroup);
export default RollingTextGroup;

export type {
RollingTextGroupInstance,
} from './types';

declare module 'vue' {
export interface GlobalComponents {
RollingTextGroup: typeof RollingTextGroup;
}
}
Loading
Loading